Giter Site home page Giter Site logo

Comments (1)

dsayling avatar dsayling commented on July 27, 2024

IMHO, I think this is beyond the scope of this library.

As a wrapper around the library - caching these or performing a GET before the POST creates a possibly complicated state management system. Since update_cases is a POST, it is therefor idempotent and this behavior would go against the spirit of a REST wrapper. You could take it up with testrail/gurock and suggest a non-idempotent PUT for update_run for adding/removing.

You yourself can easily subclass and override the methods (or provide custom methods) around these API calls.

e.g. a local caching implementation

from testrail_api import TestRailAPI

_run_map = {}

class TestRailClient(TestRailAPI):

    def update_runs_add(self, run_id, **kwargs):
        if _case_ids := _run_map.get(run_id):
            case_ids = list(set(kwargs.get('case_ids', []) + _case_ids)))
            kwargs['case_ids']  = case_ids
        else:
            _run_map[run_id] = kwargs.get('case_ids')
        return self.runs.update_runs(run_id, **kwargs)
   
    def update_runs_remove(self, run_id, **kwargs):
        if _case_ids := _run_map.get(run_id):
            case_ids = list(set(_case_ids).difference(kwargs.get('case_ids', [])))
            kwargs['case_ids']  = case_ids
        else:
            raise ValueError("No case Ids to remove from run")
        return self.runs.update_runs(run_id, **kwargs)

    ....

from testrail-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.