Skip to content

Commit 5d48db2

Browse files
micha91ewuerger
authored andcommitted
refactor: enhance readability
1 parent 6859243 commit 5d48db2

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

polarion_rest_api_client/clients/test_parameters.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,13 @@ def _split_into_batches(
6464
yield list(group)
6565

6666
def _create(self, items: list[dm.TestRunParameter]):
67+
"""Call only with items with common test_run_id."""
68+
test_run_id = items[0].test_run_id
6769
body = _build_post_body(items)
6870

6971
response = post_test_run_test_parameters.sync_detailed(
7072
self._project_id,
71-
items[0].test_run_id,
73+
test_run_id,
7274
client=self._client.client,
7375
body=body,
7476
)
@@ -82,6 +84,8 @@ def _create(self, items: list[dm.TestRunParameter]):
8284
)
8385

8486
def _delete(self, items: list[dm.TestRunParameter]):
87+
"""Call only with items with common test_run_id."""
88+
test_run_id = items[0].test_run_id
8589
body = api_models.TestparametersListDeleteRequest(
8690
data=[
8791
api_models.TestparametersListDeleteRequestDataItem(
@@ -94,7 +98,7 @@ def _delete(self, items: list[dm.TestRunParameter]):
9498

9599
response = delete_test_run_test_parameters.sync_detailed(
96100
self._project_id,
97-
items[0].test_run_id,
101+
test_run_id,
98102
client=self._client.client,
99103
body=body,
100104
)
@@ -150,14 +154,16 @@ def _split_into_batches(
150154
yield list(group)
151155

152156
def _create(self, items: list[dm.TestRecordParameter]):
157+
"""Call only with items with common test_records."""
158+
test_record = items[0].test_record
153159
body = _build_post_body(items)
154160

155161
response = post_test_record_test_parameters.sync_detailed(
156162
self._project_id,
157-
items[0].test_record.test_run_id,
158-
items[0].test_record.work_item_project_id,
159-
items[0].test_record.work_item_id,
160-
str(items[0].test_record.iteration),
163+
test_record.test_run_id,
164+
test_record.work_item_project_id,
165+
test_record.work_item_id,
166+
str(test_record.iteration),
161167
client=self._client.client,
162168
body=body,
163169
)
@@ -166,12 +172,14 @@ def _create(self, items: list[dm.TestRecordParameter]):
166172
def _delete(self, items: list[dm.TestRecordParameter]):
167173
"""We expect only one TestRecordParameter for deletion."""
168174
assert len(items) == 1
175+
test_record = items[0].test_record
176+
169177
response = delete_test_record_test_parameter.sync_detailed(
170178
self._project_id,
171-
items[0].test_record.test_run_id,
172-
items[0].test_record.work_item_project_id,
173-
items[0].test_record.work_item_id,
174-
str(items[0].test_record.iteration),
179+
test_record.test_run_id,
180+
test_record.work_item_project_id,
181+
test_record.work_item_id,
182+
str(test_record.iteration),
175183
items[0].name,
176184
client=self._client.client,
177185
)

0 commit comments

Comments
 (0)