Skip to content

Commit

Permalink
fix: use test run id from response on creation
Browse files Browse the repository at this point in the history
  • Loading branch information
micha91 committed Oct 16, 2024
1 parent e9afc9c commit 0973601
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions polarion_rest_api_client/clients/test_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ def _create(self, items: list[dm.TestRun]):
)

self._raise_on_error(response)
assert (
isinstance(response.parsed, api_models.TestrunsListPostResponse)
and response.parsed.data
)
if response.parsed and response.parsed.data:
for i, data in enumerate(response.parsed.data):
assert data.id
items[i].id = data.id.split("/")[-1]

def _delete(self, items: dm.TestRun | list[dm.TestRun]):
raise NotImplementedError
Expand Down
6 changes: 2 additions & 4 deletions polarion_rest_api_client/clients/work_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,9 @@ def _post_work_item_batch(
isinstance(response.parsed, api_models.WorkitemsListPostResponse)
and response.parsed.data
)
counter = 0
for work_item_res in response.parsed.data:
for index, work_item_res in enumerate(response.parsed.data):
assert work_item_res.id
work_item_objs[counter].id = work_item_res.id.split("/")[-1]
counter += 1
work_item_objs[index].id = work_item_res.id.split("/")[-1]

def _calculate_post_work_item_request_sizes(
self,
Expand Down
2 changes: 2 additions & 0 deletions tests/test_client_testruns.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ def test_create_test_runs(
expected_req = json.load(f)

assert req_data == expected_req
assert tr_1.id == "MyTestRunId"
assert tr_2.id == "MyTestRunId2"


def test_update_test_run(
Expand Down

0 comments on commit 0973601

Please sign in to comment.