Giter Site home page Giter Site logo

Comments (4)

elliotweiser avatar elliotweiser commented on July 27, 2024

FWIW, I'm looking into this myself and will share my workaround once I get it working. Assuming it works as expected, I'll submit a PR.

from testrail-api.

elliotweiser avatar elliotweiser commented on July 27, 2024

On closer inspection, it actually looks like latest version of (hosted) TestRail has a problem with this API as well. I'll probably need to switch to update_case until server side fix is ready. Then we can worry about client-side issue :)

from testrail-api.

dsayling avatar dsayling commented on July 27, 2024

So I played around with the request with a single-suite project and multi-suite project and the documentation is right, except for one point.

Suite ID is required even for projects in single suite mode. The suite_id belongs in the path, with the case_ids to update in the request body.

Effectively the method should be like this

    def update_cases(self, suite_id: int, case_ids: List[int], **kwargs) -> dict:
        """
        Updates multiple test cases with the same values, such as setting a set
        of test cases to High priority. This does not support updating multiple
        test cases with different values per test case.

        Note: The online documentation is wrong. The suite_id is required in
        single suite mode as well.

        :param suite_id:
            The ID of the suite
        :case_ids: List[int]
            The IDs of the test cases to update with the kwargs
        :param kwargs:
            :key title: str
                The title of the test case
            :key section_id: int
                The ID of the section (requires TestRail 6.5.2 or later)
            :key template_id: int
                The ID of the template (requires TestRail 5.2 or later)
            :key type_id: int
                The ID of the case type
            :key priority_id: int
                The ID of the case priority
            :key estimate: str
                The estimate, e.g. "30s" or "1m 45s"
            :key milestone_id: int
                The ID of the milestone to link to the test case
            :key refs: str
                A comma-separated list of references/requirements
        """
        kwargs.update({"case_ids": case_ids})
        return self.s.post(endpoint=f"update_cases/{suite_id}", json=kwargs)

I'll work on a PR.

from testrail-api.

dsayling avatar dsayling commented on July 27, 2024

Just for confirmation via curl that suite id is required for update_cases.

Suite mode of the project (1 for single suite mode, 2 for single suite + baselines, 3 for multiple suites)

⇒ curl -H "Content-Type: application/json" -u "$TESTRAIL_USR:$TESTRAIL_PSW" https://*******/index.php\?/api/v2/get_project/77 | jq                                                                                                                               
{
  "id": 77,
  "name": "Testrail Training",
  "announcement": "This project is used for testrail training.",
  "show_announcement": true,
  "is_completed": false,
  "completed_on": null,
  "suite_mode": 1,
  "default_role_id": null,
  "case_statuses_enabled": false,
  "url": "https://*****/index.php?/projects/overview/77",
  "users": [
    ....
  ],
  "groups": []
}

⇒ curl -H "Content-Type: application/json" -u "$TESTRAIL_USR:$TESTRAIL_PSW" https://******/index.php\?/api/v2/get_suites/77 | jq                                                                                                                                
[
  {
    "id": 27561,
    "name": "Master",
    "description": "Test Suite Description\r\n",
    "project_id": 77,
    "is_master": true,
    "is_baseline": false,
    "is_completed": false,
    "completed_on": null,
    "url": "https://*******/index.php?/suites/view/27561"
  }
]

⇒ curl -H "Content-Type: application/json" -u "$TESTRAIL_USR:$TESTRAIL_PSW" https://*********/index.php\?/api/v2/update_cases -d '{"custom_automation_bucket": [2,3], "case_ids": [4477220, 4477221]}'                                                             
{"error":"Field :suite_id is a required field."}%                                                                                                                                                                                                                                                                 

⇒ curl -H "Content-Type: application/json" -u "$TESTRAIL_USR:$TESTRAIL_PSW" https://*********/index.php\?/api/v2/update_cases/27561 -d '{"custom_automation_bucket": [2,3], "case_ids": [4477220, 4477221]}' | jq                                                  
{
  "updated_cases": [
    {
      "id": 4477220,
      "title": "[Negative] Making requests with improper authorization header",
      "section_id": 246871,
      "template_id": 2,
      "type_id": 7,
      "priority_id": 1,
      "milestone_id": null,
      "refs": "GROW-2566,GROW-2219,GROW-2568",
      "created_by": 196,
      "created_on": 1666373401,
      "updated_by": 196,
      "updated_on": 1666631763,
      "estimate": null,
      "estimate_forecast": null,
      "suite_id": 27561,
      "display_order": 2,
      "is_deleted": 0,
      "case_assignedto_id": null,
      "custom_automation_type": null,
      "custom_automation_state": null,
      "custom_approval_status": null,
      "custom_automation_category": 1,
      "custom_preconds": null,
      "custom_steps_separated": [
	....
      ],
      "custom_mission": null,
      "custom_goals": null,
      "custom_automation_comments": null,
      "comments": [],
      "custom_system_domain": [
        6
      ],
      "custom_automation_bucket": [
        2,
        3
      ],
      "custom_product_feature": [
        12,
        21
      ]
    },
    {
      "id": 4477221,
      "title": "[Positive] Making requests with correct authorization header",
      "section_id": 246871,
      "template_id": 2,
      "type_id": 7,
      "priority_id": 1,
      "milestone_id": null,
      "refs": "GROW-2566,GROW-2219,GROW-2568",
      "created_by": 196,
      "created_on": 1666373402,
      "updated_by": 196,
      "updated_on": 1666631763,
      "estimate": null,
      "estimate_forecast": null,
      "suite_id": 27561,
      "display_order": 3,
      "is_deleted": 0,
      "case_assignedto_id": null,
      "custom_automation_type": null,
      "custom_automation_state": null,
      "custom_approval_status": null,
      "custom_automation_category": 1,
      "custom_preconds": null,
      "custom_steps_separated": [
	....
      ],
      "custom_mission": null,
      "custom_goals": null,
      "custom_automation_comments": null,
      "comments": [],
      "custom_system_domain": [
        6
      ],
      "custom_automation_bucket": [
        2,
        3
      ],
      "custom_product_feature": [
        12,
        21
      ]
    }
  ]
}

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.