Skip to content

Commit 1a85627

Browse files
committed
Add uuid argument to client.RP.start_test_item method
1 parent 8632c00 commit 1a85627

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## [Unreleased]
44
### Added
55
- `match_pattern` and `translate_glob_to_regex`, `normalize_caseless`, `caseless_equal` functions in `helpers` module, by @HardNorth
6+
- `client.RP.start_test_item` method and all its children now accept `uuid` argument, by @HardNorth
67
### Removed
78
- `Python 3.7` support, by @HardNorth
89

reportportal_client/aio/client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ async def start_test_item(
300300
has_stats: Optional[bool] = True,
301301
retry: Optional[bool] = False,
302302
retry_of: Optional[str] = None,
303+
uuid: Optional[str] = None,
303304
**_: Any,
304305
) -> Optional[str]:
305306
"""Start Test Case/Suite/Step/Nested Step Item.
@@ -321,6 +322,7 @@ async def start_test_item(
321322
:param retry: Used to report retry of the test. Allowed values: "True" or "False".
322323
:param retry_of: For retry mode specifies which test item will be marked as retried. Should be used
323324
with the 'retry' parameter.
325+
:param uuid: Test Item UUID to use on start (overrides server one, should be globally unique).
324326
:return: Test Item UUID if successfully started or None.
325327
"""
326328
if parent_item_id:
@@ -340,6 +342,7 @@ async def start_test_item(
340342
retry=retry,
341343
test_case_id=test_case_id,
342344
retry_of=retry_of,
345+
uuid=uuid,
343346
).payload
344347

345348
response = await AsyncHttpRequest((await self.session()).post, url=url, json=request_payload).make()
@@ -763,6 +766,7 @@ async def start_test_item(
763766
retry: bool = False,
764767
test_case_id: Optional[str] = None,
765768
retry_of: Optional[str] = None,
769+
uuid: Optional[str] = None,
766770
**kwargs: Any,
767771
) -> Optional[str]:
768772
"""Start Test Case/Suite/Step/Nested Step Item.
@@ -783,6 +787,7 @@ async def start_test_item(
783787
:param test_case_id: A unique ID of the current Step.
784788
:param retry_of: For retry mode specifies which test item will be marked as retried. Should be used
785789
with the 'retry' parameter.
790+
:param uuid: Test Item UUID to use on start (overrides server one, should be globally unique).
786791
:return: Test Item UUID if successfully started or None.
787792
"""
788793
item_id = await self.__client.start_test_item(
@@ -799,6 +804,7 @@ async def start_test_item(
799804
retry=retry,
800805
test_case_id=test_case_id,
801806
retry_of=retry_of,
807+
uuid=uuid,
802808
**kwargs,
803809
)
804810
if item_id and item_id is not NOT_FOUND:
@@ -1207,6 +1213,7 @@ def start_test_item(
12071213
retry: bool = False,
12081214
test_case_id: Optional[str] = None,
12091215
retry_of: Optional[str] = None,
1216+
uuid: Optional[str] = None,
12101217
**kwargs: Any,
12111218
) -> Task[Optional[str]]:
12121219
"""Start Test Case/Suite/Step/Nested Step Item.
@@ -1227,6 +1234,7 @@ def start_test_item(
12271234
:param test_case_id: A unique ID of the current Step.
12281235
:param retry_of: For retry mode specifies which test item will be marked as retried. Should be used
12291236
with the 'retry' parameter.
1237+
:param uuid: Test Item UUID to use on start (overrides server one, should be globally unique).
12301238
:return: Test Item UUID if successfully started or None.
12311239
"""
12321240
item_id_coro = self.__client.start_test_item(
@@ -1243,6 +1251,7 @@ def start_test_item(
12431251
retry=retry,
12441252
test_case_id=test_case_id,
12451253
retry_of=retry_of,
1254+
uuid=uuid,
12461255
**kwargs,
12471256
)
12481257
item_id_task = self.create_task(item_id_coro)

reportportal_client/client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ def start_test_item(
170170
retry: Optional[bool] = False,
171171
test_case_id: Optional[str] = None,
172172
retry_of: Optional[str] = None,
173+
uuid: Optional[str] = None,
173174
**kwargs: Any,
174175
) -> Optional[str]:
175176
"""Start Test Case/Suite/Step/Nested Step Item.
@@ -190,6 +191,7 @@ def start_test_item(
190191
:param test_case_id: A unique ID of the current Step.
191192
:param retry_of: For retry mode specifies which test item will be marked as retried. Should be used
192193
with the 'retry' parameter.
194+
:param uuid: Test Item UUID to use on start (overrides server one, should be globally unique).
193195
:return: Test Item UUID if successfully started or None.
194196
"""
195197
raise NotImplementedError('"start_test_item" method is not implemented!')
@@ -610,6 +612,7 @@ def start_test_item(
610612
retry: bool = False,
611613
test_case_id: Optional[str] = None,
612614
retry_of: Optional[str] = None,
615+
uuid: Optional[str] = None,
613616
**_: Any,
614617
) -> Optional[str]:
615618
"""Start Test Case/Suite/Step/Nested Step Item.
@@ -630,6 +633,7 @@ def start_test_item(
630633
:param test_case_id: A unique ID of the current Step.
631634
:param retry_of: For retry mode specifies which test item will be marked as retried. Should be used
632635
with the 'retry' parameter.
636+
:param uuid: Test Item UUID to use on start (overrides server one, should be globally unique).
633637
:return: Test Item UUID if successfully started or None.
634638
"""
635639
if parent_item_id is NOT_FOUND:
@@ -652,6 +656,7 @@ def start_test_item(
652656
retry=retry,
653657
test_case_id=test_case_id,
654658
retry_of=retry_of,
659+
uuid=uuid,
655660
).payload
656661

657662
response = HttpRequest(

reportportal_client/core/rp_requests.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ class ItemStartRequest(RPRequestBase):
287287
retry: Optional[bool]
288288
retry_of: Optional[str]
289289
test_case_id: Optional[str]
290+
uuid: Optional[str]
290291

291292
@staticmethod
292293
def _create_request(**kwargs) -> dict:
@@ -310,6 +311,9 @@ def _create_request(**kwargs) -> dict:
310311
if parameters is not None and isinstance(parameters, dict):
311312
parameters = dict_to_payload(kwargs["parameters"])
312313
request["parameters"] = parameters
314+
uuid = kwargs.get("uuid", None)
315+
if uuid:
316+
request["uuid"] = uuid
313317
return request
314318

315319
@property
@@ -527,7 +531,7 @@ def __init__(self, log_reqs: List[Union[RPRequestLog, AsyncRPRequestLog]]) -> No
527531

528532
def __get_file(self, rp_file) -> Tuple[str, tuple]:
529533
"""Form a tuple for the single file."""
530-
return ("file", (rp_file.name, rp_file.content, rp_file.content_type or self.default_content))
534+
return "file", (rp_file.name, rp_file.content, rp_file.content_type or self.default_content)
531535

532536
def _get_files(self) -> List[Tuple[str, tuple]]:
533537
"""Get list of files for the JSON body."""

0 commit comments

Comments
 (0)