Skip to content

Commit 00803f1

Browse files
authored
Merge pull request #238 from reportportal/develop
Release
2 parents 409f3a6 + 7469374 commit 00803f1

File tree

6 files changed

+164
-108
lines changed

6 files changed

+164
-108
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Changelog
22

33
## [Unreleased]
4+
### Removed
5+
- Retries of requests ended with `504` HTTP status code, since it's not clear if the request was delivered or not, by @HardNorth
6+
### Changed
7+
- `client.RP.start_test_item` method and all its children now accept `retry_of` argument, by @HardNorth
8+
- `client.RP.finish_test_item` method and all its children now accept `retry_of` argument, by @HardNorth
9+
- `client.RP.finish_test_item` method and all its children now accept `test_case_id` argument, by @HardNorth
10+
11+
## [5.5.7]
412
### Added
513
- `helpers.to_bool` function, by @HardNorth
614
- Official `Python 3.12` support, by @HardNorth

reportportal_client/_internal/aio/http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
DEFAULT_RETRY_NUMBER: int = 5
3434
DEFAULT_RETRY_DELAY: float = 0.005
3535
THROTTLING_STATUSES: set = {425, 429}
36-
RETRY_STATUSES: set = {408, 500, 502, 503, 504, 507}.union(THROTTLING_STATUSES)
36+
RETRY_STATUSES: set = {408, 500, 502, 503, 507}.union(THROTTLING_STATUSES)
3737

3838

3939
class RetryClass(int, Enum):

reportportal_client/aio/client.py

Lines changed: 87 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def __init__(
109109
launch_uuid_print: bool = False,
110110
print_output: OutputType = OutputType.STDOUT,
111111
truncate_attributes: bool = True,
112-
**kwargs: Any
112+
**_: Any
113113
) -> None:
114114
"""Initialize the class instance with arguments.
115115
@@ -157,7 +157,7 @@ async def session(self) -> RetryingClientSession:
157157
if self._session:
158158
return self._session
159159

160-
if self.verify_ssl is None or (type(self.verify_ssl) == bool and not self.verify_ssl):
160+
if self.verify_ssl is None or (type(self.verify_ssl) is bool and not self.verify_ssl):
161161
ssl_config = False
162162
else:
163163
if type(self.verify_ssl) is str:
@@ -183,7 +183,7 @@ async def session(self) -> RetryingClientSession:
183183
}
184184

185185
if self.http_timeout:
186-
if type(self.http_timeout) == tuple:
186+
if type(self.http_timeout) is tuple:
187187
connect_timeout, read_timeout = self.http_timeout
188188
else:
189189
connect_timeout, read_timeout = self.http_timeout, self.http_timeout
@@ -230,7 +230,7 @@ async def start_launch(self,
230230
attributes: Optional[Union[list, dict]] = None,
231231
rerun: bool = False,
232232
rerun_of: Optional[str] = None,
233-
**kwargs) -> Optional[str]:
233+
**_) -> Optional[str]:
234234
"""Start a new Launch with the given arguments.
235235
236236
:param name: Launch name.
@@ -279,8 +279,9 @@ async def start_test_item(self,
279279
parameters: Optional[dict] = None,
280280
code_ref: Optional[str] = None,
281281
test_case_id: Optional[str] = None,
282-
has_stats: bool = True,
283-
retry: bool = False,
282+
has_stats: Optional[bool] = True,
283+
retry: Optional[bool] = False,
284+
retry_of: Optional[str] = None,
284285
**_: Any) -> Optional[str]:
285286
"""Start Test Case/Suite/Step/Nested Step Item.
286287
@@ -299,6 +300,8 @@ async def start_test_item(self,
299300
:param test_case_id: A unique ID of the current Step.
300301
:param has_stats: Set to False if test item is a Nested Step.
301302
:param retry: Used to report retry of the test. Allowed values: "True" or "False".
303+
:param retry_of: For retry mode specifies which test item will be marked as retried. Should be used
304+
with the 'retry' parameter.
302305
:return: Test Item UUID if successfully started or None.
303306
"""
304307
if parent_item_id:
@@ -316,7 +319,8 @@ async def start_test_item(self,
316319
has_stats=has_stats,
317320
parameters=parameters,
318321
retry=retry,
319-
test_case_id=test_case_id
322+
test_case_id=test_case_id,
323+
retry_of=retry_of
320324
).payload
321325

322326
response = await AsyncHttpRequest((await self.session()).post, url=url, json=request_payload).make()
@@ -334,25 +338,30 @@ async def finish_test_item(self,
334338
item_id: Union[str, Task[str]],
335339
end_time: str,
336340
*,
337-
status: str = None,
338-
description: str = None,
341+
status: Optional[str] = None,
342+
description: Optional[str] = None,
339343
attributes: Optional[Union[list, dict]] = None,
344+
test_case_id: Optional[str] = None,
340345
issue: Optional[Issue] = None,
341-
retry: bool = False,
342-
**kwargs: Any) -> Optional[str]:
346+
retry: Optional[bool] = False,
347+
retry_of: Optional[str] = None,
348+
**_: Any) -> Optional[str]:
343349
"""Finish Test Suite/Case/Step/Nested Step Item.
344350
345-
:param launch_uuid: A launch UUID where to finish the Test Item.
346-
:param item_id: ID of the Test Item.
347-
:param end_time: The Item end time.
348-
:param status: Test status. Allowed values:
349-
PASSED, FAILED, STOPPED, SKIPPED, INTERRUPTED, CANCELLED, INFO, WARN or None.
350-
:param description: Test Item description. Overrides description from start request.
351-
:param attributes: Test Item attributes(tags). Pairs of key and value. These attributes override
352-
attributes on start Test Item call.
353-
:param issue: Issue which will be attached to the current Item.
354-
:param retry: Used to report retry of the test. Allowed values: "True" or "False".
355-
:return: Response message.
351+
:param launch_uuid: A launch UUID where to finish the Test Item.
352+
:param item_id: ID of the Test Item.
353+
:param end_time: The Item end time.
354+
:param status: Test status. Allowed values:
355+
PASSED, FAILED, STOPPED, SKIPPED, INTERRUPTED, CANCELLED, INFO, WARN or None.
356+
:param description: Test Item description. Overrides description from start request.
357+
:param attributes: Test Item attributes(tags). Pairs of key and value. These attributes override
358+
attributes on start Test Item call.
359+
:param test_case_id: A unique ID of the current Step. Overrides passed on start request.
360+
:param issue: Issue which will be attached to the current Item.
361+
:param retry: Used to report retry of the test. Allowed values: "True" or "False".
362+
:param retry_of: For retry mode specifies which test item will be marked as retried. Should be used
363+
with the 'retry' parameter.
364+
:return: Response message.
356365
"""
357366
url = self.__get_item_url(item_id)
358367
request_payload = AsyncItemFinishRequest(
@@ -361,9 +370,11 @@ async def finish_test_item(self,
361370
status,
362371
attributes=verify_value_length(attributes) if self.truncate_attributes else attributes,
363372
description=description,
373+
test_case_id=test_case_id,
364374
is_skipped_an_issue=self.is_skipped_an_issue,
365375
issue=issue,
366-
retry=retry
376+
retry=retry,
377+
retry_of=retry_of
367378
).payload
368379
response = await AsyncHttpRequest((await self.session()).put, url=url, json=request_payload).make()
369380
if not response:
@@ -377,15 +388,15 @@ async def finish_launch(self,
377388
launch_uuid: Union[str, Task[str]],
378389
end_time: str,
379390
*,
380-
status: str = None,
391+
status: Optional[str] = None,
381392
attributes: Optional[Union[list, dict]] = None,
382393
**kwargs: Any) -> Optional[str]:
383394
"""Finish a Launch.
384395
385396
:param launch_uuid: A Launch UUID to finish.
386397
:param end_time: Launch end time.
387398
:param status: Launch status. Can be one of the followings:
388-
PASSED, FAILED, STOPPED, SKIPPED, INTERRUPTED, CANCELLED.
399+
PASSED, FAILED, STOPPED, SKIPPED, INTERRUPTED, CANCELLED or None.
389400
:param attributes: Launch attributes. These attributes override attributes on Start Launch call.
390401
:return: Response message or None.
391402
"""
@@ -530,7 +541,7 @@ def clone(self) -> 'Client':
530541
"""Clone the client object, set current Item ID as cloned item ID.
531542
532543
:return: Cloned client object
533-
:rtype: AsyncRPClient
544+
:rtype: Client
534545
"""
535546
cloned = Client(
536547
endpoint=self.endpoint,
@@ -721,6 +732,7 @@ async def start_test_item(self,
721732
code_ref: Optional[str] = None,
722733
retry: bool = False,
723734
test_case_id: Optional[str] = None,
735+
retry_of: Optional[str] = None,
724736
**kwargs: Any) -> Optional[str]:
725737
"""Start Test Case/Suite/Step/Nested Step Item.
726738
@@ -738,13 +750,15 @@ async def start_test_item(self,
738750
:param code_ref: Physical location of the Test Item.
739751
:param retry: Used to report retry of the test. Allowed values: "True" or "False".
740752
:param test_case_id: A unique ID of the current Step.
753+
:param retry_of: For retry mode specifies which test item will be marked as retried. Should be used
754+
with the 'retry' parameter.
741755
:return: Test Item UUID if successfully started or None.
742756
"""
743757
item_id = await self.__client.start_test_item(self.launch_uuid, name, start_time, item_type,
744758
description=description, attributes=attributes,
745759
parameters=parameters, parent_item_id=parent_item_id,
746760
has_stats=has_stats, code_ref=code_ref, retry=retry,
747-
test_case_id=test_case_id, **kwargs)
761+
test_case_id=test_case_id, retry_of=retry_of, **kwargs)
748762
if item_id and item_id is not NOT_FOUND:
749763
logger.debug('start_test_item - ID: %s', item_id)
750764
self._add_current_item(item_id)
@@ -753,35 +767,39 @@ async def start_test_item(self,
753767
async def finish_test_item(self,
754768
item_id: str,
755769
end_time: str,
756-
status: str = None,
770+
status: Optional[str] = None,
757771
issue: Optional[Issue] = None,
758772
attributes: Optional[Union[list, dict]] = None,
759773
description: str = None,
760774
retry: bool = False,
775+
test_case_id: Optional[str] = None,
776+
retry_of: Optional[str] = None,
761777
**kwargs: Any) -> Optional[str]:
762778
"""Finish Test Suite/Case/Step/Nested Step Item.
763779
764-
:param item_id: ID of the Test Item.
765-
:param end_time: The Item end time.
766-
:param status: Test status. Allowed values:
767-
PASSED, FAILED, STOPPED, SKIPPED, INTERRUPTED, CANCELLED, INFO, WARN or None.
768-
:param issue: Issue which will be attached to the current Item.
769-
:param attributes: Test Item attributes(tags). Pairs of key and value. These attributes override
770-
attributes on start Test Item call.
771-
:param description: Test Item description. Overrides description from start request.
772-
:param retry: Used to report retry of the test. Allowed values: "True" or "False".
773-
:return: Response message.
774-
"""
775-
result = await self.__client.finish_test_item(self.launch_uuid, item_id, end_time, status=status,
776-
issue=issue, attributes=attributes,
777-
description=description,
778-
retry=retry, **kwargs)
780+
:param item_id: ID of the Test Item.
781+
:param end_time: The Item end time.
782+
:param status: Test status. Allowed values:
783+
PASSED, FAILED, STOPPED, SKIPPED, INTERRUPTED, CANCELLED, INFO, WARN or None.
784+
:param issue: Issue which will be attached to the current Item.
785+
:param attributes: Test Item attributes(tags). Pairs of key and value. These attributes override
786+
attributes on start Test Item call.
787+
:param description: Test Item description. Overrides description from start request.
788+
:param retry: Used to report retry of the test. Allowed values: "True" or "False".
789+
:param test_case_id: A unique ID of the current Step.
790+
:param retry_of: For retry mode specifies which test item will be marked as retried. Should be used
791+
with the 'retry' parameter.
792+
:return: Response message.
793+
"""
794+
result = await self.__client.finish_test_item(
795+
self.launch_uuid, item_id, end_time, status=status, issue=issue, attributes=attributes,
796+
description=description, retry=retry, test_case_id=test_case_id, retry_of=retry_of, **kwargs)
779797
self._remove_current_item()
780798
return result
781799

782800
async def finish_launch(self,
783801
end_time: str,
784-
status: str = None,
802+
status: Optional[str] = None,
785803
attributes: Optional[Union[list, dict]] = None,
786804
**kwargs: Any) -> Optional[str]:
787805
"""Finish a Launch.
@@ -1132,6 +1150,7 @@ def start_test_item(self,
11321150
code_ref: Optional[str] = None,
11331151
retry: bool = False,
11341152
test_case_id: Optional[str] = None,
1153+
retry_of: Optional[str] = None,
11351154
**kwargs: Any) -> Task[str]:
11361155
"""Start Test Case/Suite/Step/Nested Step Item.
11371156
@@ -1149,50 +1168,56 @@ def start_test_item(self,
11491168
:param code_ref: Physical location of the Test Item.
11501169
:param retry: Used to report retry of the test. Allowed values: "True" or "False".
11511170
:param test_case_id: A unique ID of the current Step.
1171+
:param retry_of: For retry mode specifies which test item will be marked as retried. Should be used
1172+
with the 'retry' parameter.
11521173
:return: Test Item UUID if successfully started or None.
11531174
"""
11541175
item_id_coro = self.__client.start_test_item(self.launch_uuid, name, start_time, item_type,
11551176
description=description, attributes=attributes,
11561177
parameters=parameters, parent_item_id=parent_item_id,
11571178
has_stats=has_stats, code_ref=code_ref, retry=retry,
1158-
test_case_id=test_case_id, **kwargs)
1179+
test_case_id=test_case_id, retry_of=retry_of, **kwargs)
11591180
item_id_task = self.create_task(item_id_coro)
11601181
self._add_current_item(item_id_task)
11611182
return item_id_task
11621183

11631184
def finish_test_item(self,
11641185
item_id: Task[str],
11651186
end_time: str,
1166-
status: str = None,
1187+
status: Optional[str] = None,
11671188
issue: Optional[Issue] = None,
11681189
attributes: Optional[Union[list, dict]] = None,
11691190
description: str = None,
11701191
retry: bool = False,
1192+
test_case_id: Optional[str] = None,
1193+
retry_of: Optional[str] = None,
11711194
**kwargs: Any) -> Task[str]:
11721195
"""Finish Test Suite/Case/Step/Nested Step Item.
11731196
1174-
:param item_id: ID of the Test Item.
1175-
:param end_time: The Item end time.
1176-
:param status: Test status. Allowed values:
1177-
PASSED, FAILED, STOPPED, SKIPPED, INTERRUPTED, CANCELLED, INFO, WARN or None.
1178-
:param issue: Issue which will be attached to the current Item.
1179-
:param attributes: Test Item attributes(tags). Pairs of key and value. These attributes override
1180-
attributes on start Test Item call.
1181-
:param description: Test Item description. Overrides description from start request.
1182-
:param retry: Used to report retry of the test. Allowed values: "True" or "False".
1183-
:return: Response message.
1184-
"""
1185-
result_coro = self.__client.finish_test_item(self.launch_uuid, item_id, end_time, status=status,
1186-
issue=issue, attributes=attributes,
1187-
description=description,
1188-
retry=retry, **kwargs)
1197+
:param item_id: ID of the Test Item.
1198+
:param end_time: The Item end time.
1199+
:param status: Test status. Allowed values:
1200+
PASSED, FAILED, STOPPED, SKIPPED, INTERRUPTED, CANCELLED, INFO, WARN or None.
1201+
:param issue: Issue which will be attached to the current Item.
1202+
:param attributes: Test Item attributes(tags). Pairs of key and value. These attributes override
1203+
attributes on start Test Item call.
1204+
:param description: Test Item description. Overrides description from start request.
1205+
:param retry: Used to report retry of the test. Allowed values: "True" or "False".
1206+
:param test_case_id: A unique ID of the current Step.
1207+
:param retry_of: For retry mode specifies which test item will be marked as retried. Should be used
1208+
with the 'retry' parameter.
1209+
:return: Response message.
1210+
"""
1211+
result_coro = self.__client.finish_test_item(
1212+
self.launch_uuid, item_id, end_time, status=status, issue=issue, attributes=attributes,
1213+
description=description, retry=retry, test_case_id=test_case_id, retry_of=retry_of, **kwargs)
11891214
result_task = self.create_task(result_coro)
11901215
self._remove_current_item()
11911216
return result_task
11921217

11931218
def finish_launch(self,
11941219
end_time: str,
1195-
status: str = None,
1220+
status: Optional[str] = None,
11961221
attributes: Optional[Union[list, dict]] = None,
11971222
**kwargs: Any) -> Task[str]:
11981223
"""Finish a Launch.

0 commit comments

Comments
 (0)