From 82bb4422169b7e7c25abeb1045d19cc41449a08d Mon Sep 17 00:00:00 2001 From: Marcin Antczak Date: Wed, 19 Jan 2022 13:53:05 +0100 Subject: [PATCH] Add post_item_workflow_transitions method --- README.md | 1 + py_jama_rest_client/client.py | 25 +++++++++++++++++++++++++ test/test_jamaClient.py | 8 ++++++++ 3 files changed, 34 insertions(+) diff --git a/README.md b/README.md index 589884f..0e77d62 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ compatibility) - `POST` an item to a project - `POST` item attachment - `POST` item sync +- `POST` Executes a workflow transition for the item with the specified item ID - `POST` a tag to an item - `PUT` an item - `PUT` item lock diff --git a/py_jama_rest_client/client.py b/py_jama_rest_client/client.py index 0d2480c..b5e15d3 100644 --- a/py_jama_rest_client/client.py +++ b/py_jama_rest_client/client.py @@ -1193,6 +1193,31 @@ def post_item_sync(self, source_item: int, pool_item: int): JamaClient.__handle_response_status(response) return response.json()['meta']['id'] + def post_item_workflow_transitions(self, item_id, transition_id, comment=''): + """ + Executes a workflow transition for the item with the specified ID + + Args: + item_id: the api id of the item + transition_id: the api id of the tranistion status + comment: short description about the item transition + + Returns: 201 if successful + """ + resource_path = 'items/'+ str(item_id) + '/workflowtransitions' + body = { + 'transitionId': transition_id, + 'comment': comment + } + headers = {'content-type': 'application/json'} + try: + response = self.__core.post(resource_path, data=json.dumps(body), headers=headers) + except CoreException as err: + py_jama_rest_client_logger.error(err) + raise APIException(str(err)) + JamaClient.__handle_response_status(response) + return response.status_code + def post_relationship(self, from_item: int, to_item: int, relationship_type=None): """ diff --git a/test/test_jamaClient.py b/test/test_jamaClient.py index 393397e..7008d94 100644 --- a/test/test_jamaClient.py +++ b/test/test_jamaClient.py @@ -188,6 +188,14 @@ def test_post_item_sync(self): sync = self.jama_client.post_item_sync(source_item, pool_item) self.assertIsNotNone(sync) + @unittest.skip('Entity Already Exists') + def test_post_item_workflow_transitions(self): + item_id = 10410 + transition_id = "566_700" + comment = "Draft to Ready for Review" + res_status = self.jama_client.post_item_workflow_transitions(item_id,transition_id,comment) + self.assertEqual(res_status, 201) + @unittest.skip('Entity Already Exists') def test_post_relationship(self): from_item = 104755