Skip to content

Commit 1cb63b5

Browse files
committed
Merge branch 'develop' into develop-no-binaries
2 parents 74cb955 + 05809d5 commit 1cb63b5

File tree

13 files changed

+457
-87
lines changed

13 files changed

+457
-87
lines changed

CHANGELOG.md

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

33
## [Unreleased]
4+
5+
## [5.6.2]
6+
### Fixed
7+
- Issue [#246](https://github.com/reportportal/client-Python/issues/246): Invalid return type, by @HardNorth
8+
### Changed
9+
- `helpers.common_helpers.gen_attributes` function now accepts refactored, by @HardNorth
10+
11+
## [5.6.1]
12+
### Added
13+
- `markdown_helpers` module in `reportportal_client.helpers` package, by @HardNorth
414
### Changed
515
- `helpers.is_binary` function to improve binary content detection, by @HardNorth
16+
- `helpers` module moved to `reportportal_client.helpers` package, by @HardNorth
617

718
## [5.6.0]
819
### Added

reportportal_client/_internal/aio/tasks.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from asyncio import Future
2020
from typing import Any, Awaitable, Coroutine, Generator, Generic, List, Optional, TypeVar, Union
2121

22+
from reportportal_client._internal.static.defines import NOT_FOUND
2223
from reportportal_client.aio.tasks import BlockingOperationError, Task
2324

2425
_T = TypeVar("_T")
@@ -54,8 +55,10 @@ def blocking_result(self) -> _T:
5455
:return: execution result or raise an error, or return immediately if already executed
5556
"""
5657
if self.done():
57-
return self.result()
58-
return self.__loop.run_until_complete(self)
58+
result = self.result()
59+
else:
60+
result = self.__loop.run_until_complete(self)
61+
return result if result is not NOT_FOUND else None
5962

6063

6164
class ThreadedTask(Generic[_T], Task[_T]):
@@ -88,7 +91,8 @@ def blocking_result(self) -> _T:
8891
:return: execution result or raise an error, or return immediately if already executed
8992
"""
9093
if self.done():
91-
return self.result()
94+
result = self.result()
95+
return result if result is not NOT_FOUND else None
9296
if not self.__loop.is_running() or self.__loop.is_closed():
9397
raise BlockingOperationError("Running loop is not alive")
9498
start_time = time.time()
@@ -97,7 +101,8 @@ def blocking_result(self) -> _T:
97101
time.sleep(sleep_time)
98102
if not self.done():
99103
raise BlockingOperationError("Timed out waiting for the task execution")
100-
return self.result()
104+
result = self.result()
105+
return result if result is not NOT_FOUND else None
101106

102107

103108
class BatchedTaskFactory:

reportportal_client/aio/client.py

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,14 @@ async def __get_item_url(self, item_id_future: Union[Optional[str], Task[Optiona
227227
item_id = await await_if_necessary(item_id_future)
228228
if item_id is NOT_FOUND or item_id is None:
229229
logger.warning("Attempt to make request for non-existent id.")
230-
return
230+
return None
231231
return root_uri_join(self.base_url_v2, "item", item_id)
232232

233233
async def __get_launch_url(self, launch_uuid_future: Union[Optional[str], Task[Optional[str]]]) -> Optional[str]:
234234
launch_uuid = await await_if_necessary(launch_uuid_future)
235235
if launch_uuid is NOT_FOUND or launch_uuid is None:
236236
logger.warning("Attempt to make request for non-existent launch.")
237-
return
237+
return None
238238
return root_uri_join(self.base_url_v2, "launch", launch_uuid, "finish")
239239

240240
async def start_launch(
@@ -272,7 +272,7 @@ async def start_launch(
272272

273273
response = await AsyncHttpRequest((await self.session()).post, url=url, json=request_payload).make()
274274
if not response:
275-
return
275+
return None
276276

277277
if not self._skip_analytics:
278278
stat_coro = async_send_event("start_launch", *agent_name_version(attributes))
@@ -347,7 +347,7 @@ async def start_test_item(
347347

348348
response = await AsyncHttpRequest((await self.session()).post, url=url, json=request_payload).make()
349349
if not response:
350-
return
350+
return None
351351
item_id = await response.id
352352
if item_id is NOT_FOUND or item_id is None:
353353
logger.warning("start_test_item - invalid response: %s", str(await response.json))
@@ -402,7 +402,7 @@ async def finish_test_item(
402402
).payload
403403
response = await AsyncHttpRequest((await self.session()).put, url=url, json=request_payload).make()
404404
if not response:
405-
return
405+
return None
406406
message = await response.message
407407
logger.debug("finish_test_item - ID: %s", await await_if_necessary(item_id))
408408
logger.debug("response message: %s", message)
@@ -437,7 +437,7 @@ async def finish_launch(
437437
(await self.session()).put, url=url, json=request_payload, name="Finish Launch"
438438
).make()
439439
if not response:
440-
return
440+
return None
441441
message = await response.message
442442
logger.debug("finish_launch - ID: %s", await await_if_necessary(launch_uuid))
443443
logger.debug("response message: %s", message)
@@ -465,15 +465,15 @@ async def update_test_item(
465465
url = root_uri_join(self.base_url_v1, "item", item_id, "update")
466466
response = await AsyncHttpRequest((await self.session()).put, url=url, json=data).make()
467467
if not response:
468-
return
468+
return None
469469
logger.debug("update_test_item - Item: %s", item_id)
470470
return await response.message
471471

472472
async def __get_launch_uuid_url(self, launch_uuid_future: Union[str, Task[str]]) -> Optional[str]:
473473
launch_uuid = await await_if_necessary(launch_uuid_future)
474474
if launch_uuid is NOT_FOUND or launch_uuid is None:
475475
logger.warning("Attempt to make request for non-existent Launch UUID.")
476-
return
476+
return None
477477
logger.debug("get_launch_info - ID: %s", launch_uuid)
478478
return root_uri_join(self.base_url_v1, "launch", "uuid", launch_uuid)
479479

@@ -486,7 +486,7 @@ async def get_launch_info(self, launch_uuid_future: Union[str, Task[str]]) -> Op
486486
url = self.__get_launch_uuid_url(launch_uuid_future)
487487
response = await AsyncHttpRequest((await self.session()).get, url=url).make()
488488
if not response:
489-
return
489+
return None
490490
launch_info = None
491491
if response.is_success:
492492
launch_info = await response.json
@@ -499,7 +499,7 @@ async def __get_item_uuid_url(self, item_uuid_future: Union[Optional[str], Task[
499499
item_uuid = await await_if_necessary(item_uuid_future)
500500
if item_uuid is NOT_FOUND or item_uuid is None:
501501
logger.warning("Attempt to make request for non-existent UUID.")
502-
return
502+
return None
503503
return root_uri_join(self.base_url_v1, "item", "uuid", item_uuid)
504504

505505
async def get_item_id_by_uuid(self, item_uuid_future: Union[str, Task[str]]) -> Optional[str]:
@@ -531,7 +531,7 @@ async def get_launch_ui_url(self, launch_uuid_future: Union[str, Task[str]]) ->
531531
launch_info = await self.get_launch_info(launch_uuid)
532532
launch_id = launch_info.get("id") if launch_info else None
533533
if not launch_id:
534-
return
534+
return None
535535
mode = launch_info.get("mode") if launch_info else None
536536
if not mode:
537537
mode = self.mode
@@ -564,7 +564,7 @@ async def log_batch(self, log_batch: Optional[List[AsyncRPRequestLog]]) -> Optio
564564
(await self.session()).post, url=url, data=AsyncRPLogBatch(log_batch).payload
565565
).make()
566566
if not response:
567-
return
567+
return None
568568
return await response.messages
569569

570570
def clone(self) -> "Client":
@@ -639,6 +639,8 @@ def launch_uuid(self) -> Optional[str]:
639639
640640
:return: UUID string.
641641
"""
642+
if self.__launch_uuid is NOT_FOUND:
643+
return None
642644
return self.__launch_uuid
643645

644646
@property
@@ -750,7 +752,7 @@ async def start_launch(
750752
name, start_time, description=description, attributes=attributes, rerun=rerun, rerun_of=rerun_of, **kwargs
751753
)
752754
self.__launch_uuid = launch_uuid
753-
return launch_uuid
755+
return self.launch_uuid
754756

755757
async def start_test_item(
756758
self,
@@ -791,7 +793,7 @@ async def start_test_item(
791793
:return: Test Item UUID if successfully started or None.
792794
"""
793795
item_id = await self.__client.start_test_item(
794-
self.launch_uuid,
796+
self.__launch_uuid,
795797
name,
796798
start_time,
797799
item_type,
@@ -842,7 +844,7 @@ async def finish_test_item(
842844
:return: Response message.
843845
"""
844846
result = await self.__client.finish_test_item(
845-
self.launch_uuid,
847+
self.__launch_uuid,
846848
item_id,
847849
end_time,
848850
status=status,
@@ -874,7 +876,7 @@ async def finish_launch(
874876
"""
875877
if self.use_own_launch:
876878
result = await self.__client.finish_launch(
877-
self.launch_uuid, end_time, status=status, attributes=attributes, **kwargs
879+
self.__launch_uuid, end_time, status=status, attributes=attributes, **kwargs
878880
)
879881
else:
880882
result = ""
@@ -915,7 +917,7 @@ async def get_launch_info(self) -> Optional[dict]:
915917
"""
916918
if not self.launch_uuid:
917919
return {}
918-
return await self.__client.get_launch_info(self.launch_uuid)
920+
return await self.__client.get_launch_info(self.__launch_uuid)
919921

920922
async def get_item_id_by_uuid(self, item_uuid: str) -> Optional[str]:
921923
"""Get Test Item ID by the given Item UUID.
@@ -931,17 +933,17 @@ async def get_launch_ui_id(self) -> Optional[int]:
931933
:return: Launch ID of the Launch. None if not found.
932934
"""
933935
if not self.launch_uuid:
934-
return
935-
return await self.__client.get_launch_ui_id(self.launch_uuid)
936+
return None
937+
return await self.__client.get_launch_ui_id(self.__launch_uuid)
936938

937939
async def get_launch_ui_url(self) -> Optional[str]:
938940
"""Get full quality URL of the current Launch.
939941
940942
:return: Launch URL string.
941943
"""
942944
if not self.launch_uuid:
943-
return
944-
return await self.__client.get_launch_ui_url(self.launch_uuid)
945+
return None
946+
return await self.__client.get_launch_ui_url(self.__launch_uuid)
945947

946948
async def get_project_settings(self) -> Optional[dict]:
947949
"""Get settings of the current Project.
@@ -972,9 +974,9 @@ async def log(
972974
"""
973975
if item_id is NOT_FOUND:
974976
logger.warning("Attempt to log to non-existent item")
975-
return
977+
return None
976978
rp_file = RPFile(**attachment) if attachment else None
977-
rp_log = AsyncRPRequestLog(self.launch_uuid, time, rp_file, item_id, level, message)
979+
rp_log = AsyncRPRequestLog(self.__launch_uuid, time, rp_file, item_id, level, message)
978980
return await self.__client.log_batch(await self._log_batcher.append_async(rp_log))
979981

980982
def clone(self) -> "AsyncRPClient":
@@ -989,7 +991,7 @@ def clone(self) -> "AsyncRPClient":
989991
endpoint=self.endpoint,
990992
project=self.project,
991993
client=cloned_client,
992-
launch_uuid=self.launch_uuid,
994+
launch_uuid=self.__launch_uuid,
993995
log_batch_size=self.log_batch_size,
994996
log_batch_payload_limit=self.log_batch_payload_limit,
995997
log_batcher=self._log_batcher,
@@ -1017,7 +1019,7 @@ class _RPClient(RP, metaclass=AbstractBaseClass):
10171019
_item_stack: LifoQueue
10181020
_log_batcher: LogBatcher
10191021
__client: Client
1020-
__launch_uuid: Optional[Task[str]]
1022+
__launch_uuid: Optional[Task[Optional[str]]]
10211023
__endpoint: str
10221024
__project: str
10231025
__step_reporter: StepReporter
@@ -1031,7 +1033,7 @@ def client(self) -> Client:
10311033
return self.__client
10321034

10331035
@property
1034-
def launch_uuid(self) -> Task[Optional[str]]:
1036+
def launch_uuid(self) -> Optional[Task[Optional[str]]]:
10351037
"""Return current Launch UUID.
10361038
10371039
:return: UUID string.
@@ -1068,7 +1070,7 @@ def __init__(
10681070
project: str,
10691071
*,
10701072
client: Optional[Client] = None,
1071-
launch_uuid: Optional[Task[str]] = None,
1073+
launch_uuid: Optional[Task[Optional[str]]] = None,
10721074
log_batch_size: int = 20,
10731075
log_batch_payload_limit: int = MAX_LOG_BATCH_PAYLOAD_SIZE,
10741076
log_batcher: Optional[LogBatcher] = None,
@@ -1555,7 +1557,7 @@ def create_task(self, coro: Coroutine[Any, Any, _T]) -> Optional[Task[_T]]:
15551557
:return: Task instance.
15561558
"""
15571559
if not getattr(self, "_loop", None):
1558-
return
1560+
return None
15591561
result = self._loop.create_task(coro)
15601562
with self._task_mutex:
15611563
self._task_list.append(result)
@@ -1742,7 +1744,7 @@ def create_task(self, coro: Coroutine[Any, Any, _T]) -> Optional[Task[_T]]:
17421744
:return: Task instance.
17431745
"""
17441746
if not getattr(self, "_loop", None):
1745-
return
1747+
return None
17461748
result = self._loop.create_task(coro)
17471749
with self._task_mutex:
17481750
tasks = self._task_list.append(result)

0 commit comments

Comments
 (0)