Skip to content

Commit

Permalink
Add uuid argument to client.RP.start_test_item method
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Dec 19, 2024
1 parent 8632c00 commit 1a85627
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [Unreleased]
### Added
- `match_pattern` and `translate_glob_to_regex`, `normalize_caseless`, `caseless_equal` functions in `helpers` module, by @HardNorth
- `client.RP.start_test_item` method and all its children now accept `uuid` argument, by @HardNorth
### Removed
- `Python 3.7` support, by @HardNorth

Expand Down
9 changes: 9 additions & 0 deletions reportportal_client/aio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ async def start_test_item(
has_stats: Optional[bool] = True,
retry: Optional[bool] = False,
retry_of: Optional[str] = None,
uuid: Optional[str] = None,
**_: Any,
) -> Optional[str]:
"""Start Test Case/Suite/Step/Nested Step Item.
Expand All @@ -321,6 +322,7 @@ async def start_test_item(
:param retry: Used to report retry of the test. Allowed values: "True" or "False".
:param retry_of: For retry mode specifies which test item will be marked as retried. Should be used
with the 'retry' parameter.
:param uuid: Test Item UUID to use on start (overrides server one, should be globally unique).
:return: Test Item UUID if successfully started or None.
"""
if parent_item_id:
Expand All @@ -340,6 +342,7 @@ async def start_test_item(
retry=retry,
test_case_id=test_case_id,
retry_of=retry_of,
uuid=uuid,
).payload

response = await AsyncHttpRequest((await self.session()).post, url=url, json=request_payload).make()
Expand Down Expand Up @@ -763,6 +766,7 @@ async def start_test_item(
retry: bool = False,
test_case_id: Optional[str] = None,
retry_of: Optional[str] = None,
uuid: Optional[str] = None,
**kwargs: Any,
) -> Optional[str]:
"""Start Test Case/Suite/Step/Nested Step Item.
Expand All @@ -783,6 +787,7 @@ async def start_test_item(
:param test_case_id: A unique ID of the current Step.
:param retry_of: For retry mode specifies which test item will be marked as retried. Should be used
with the 'retry' parameter.
:param uuid: Test Item UUID to use on start (overrides server one, should be globally unique).
:return: Test Item UUID if successfully started or None.
"""
item_id = await self.__client.start_test_item(
Expand All @@ -799,6 +804,7 @@ async def start_test_item(
retry=retry,
test_case_id=test_case_id,
retry_of=retry_of,
uuid=uuid,
**kwargs,
)
if item_id and item_id is not NOT_FOUND:
Expand Down Expand Up @@ -1207,6 +1213,7 @@ def start_test_item(
retry: bool = False,
test_case_id: Optional[str] = None,
retry_of: Optional[str] = None,
uuid: Optional[str] = None,
**kwargs: Any,
) -> Task[Optional[str]]:
"""Start Test Case/Suite/Step/Nested Step Item.
Expand All @@ -1227,6 +1234,7 @@ def start_test_item(
:param test_case_id: A unique ID of the current Step.
:param retry_of: For retry mode specifies which test item will be marked as retried. Should be used
with the 'retry' parameter.
:param uuid: Test Item UUID to use on start (overrides server one, should be globally unique).
:return: Test Item UUID if successfully started or None.
"""
item_id_coro = self.__client.start_test_item(
Expand All @@ -1243,6 +1251,7 @@ def start_test_item(
retry=retry,
test_case_id=test_case_id,
retry_of=retry_of,
uuid=uuid,
**kwargs,
)
item_id_task = self.create_task(item_id_coro)
Expand Down
5 changes: 5 additions & 0 deletions reportportal_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def start_test_item(
retry: Optional[bool] = False,
test_case_id: Optional[str] = None,
retry_of: Optional[str] = None,
uuid: Optional[str] = None,
**kwargs: Any,
) -> Optional[str]:
"""Start Test Case/Suite/Step/Nested Step Item.
Expand All @@ -190,6 +191,7 @@ def start_test_item(
:param test_case_id: A unique ID of the current Step.
:param retry_of: For retry mode specifies which test item will be marked as retried. Should be used
with the 'retry' parameter.
:param uuid: Test Item UUID to use on start (overrides server one, should be globally unique).
:return: Test Item UUID if successfully started or None.
"""
raise NotImplementedError('"start_test_item" method is not implemented!')
Expand Down Expand Up @@ -610,6 +612,7 @@ def start_test_item(
retry: bool = False,
test_case_id: Optional[str] = None,
retry_of: Optional[str] = None,
uuid: Optional[str] = None,
**_: Any,
) -> Optional[str]:
"""Start Test Case/Suite/Step/Nested Step Item.
Expand All @@ -630,6 +633,7 @@ def start_test_item(
:param test_case_id: A unique ID of the current Step.
:param retry_of: For retry mode specifies which test item will be marked as retried. Should be used
with the 'retry' parameter.
:param uuid: Test Item UUID to use on start (overrides server one, should be globally unique).
:return: Test Item UUID if successfully started or None.
"""
if parent_item_id is NOT_FOUND:
Expand All @@ -652,6 +656,7 @@ def start_test_item(
retry=retry,
test_case_id=test_case_id,
retry_of=retry_of,
uuid=uuid,
).payload

response = HttpRequest(
Expand Down
6 changes: 5 additions & 1 deletion reportportal_client/core/rp_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ class ItemStartRequest(RPRequestBase):
retry: Optional[bool]
retry_of: Optional[str]
test_case_id: Optional[str]
uuid: Optional[str]

@staticmethod
def _create_request(**kwargs) -> dict:
Expand All @@ -310,6 +311,9 @@ def _create_request(**kwargs) -> dict:
if parameters is not None and isinstance(parameters, dict):
parameters = dict_to_payload(kwargs["parameters"])
request["parameters"] = parameters
uuid = kwargs.get("uuid", None)
if uuid:
request["uuid"] = uuid
return request

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

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

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

0 comments on commit 1a85627

Please sign in to comment.