51
51
from reportportal_client ._internal .static .abstract import AbstractBaseClass , abstractmethod
52
52
53
53
# noinspection PyProtectedMember
54
- from reportportal_client ._internal .static .defines import NOT_FOUND , NOT_SET
54
+ from reportportal_client ._internal .static .defines import NOT_SET
55
55
from reportportal_client .aio .tasks import Task
56
56
from reportportal_client .client import RP , OutputType
57
57
from reportportal_client .core .rp_issues import Issue
@@ -225,14 +225,14 @@ async def close(self) -> None:
225
225
226
226
async def __get_item_url (self , item_id_future : Union [Optional [str ], Task [Optional [str ]]]) -> Optional [str ]:
227
227
item_id = await await_if_necessary (item_id_future )
228
- if item_id is NOT_FOUND or item_id is None :
228
+ if not item_id :
229
229
logger .warning ("Attempt to make request for non-existent id." )
230
230
return None
231
231
return root_uri_join (self .base_url_v2 , "item" , item_id )
232
232
233
233
async def __get_launch_url (self , launch_uuid_future : Union [Optional [str ], Task [Optional [str ]]]) -> Optional [str ]:
234
234
launch_uuid = await await_if_necessary (launch_uuid_future )
235
- if launch_uuid is NOT_FOUND or launch_uuid is None :
235
+ if not launch_uuid :
236
236
logger .warning ("Attempt to make request for non-existent launch." )
237
237
return None
238
238
return root_uri_join (self .base_url_v2 , "launch" , launch_uuid , "finish" )
@@ -270,7 +270,9 @@ async def start_launch(
270
270
rerun_of = rerun_of ,
271
271
).payload
272
272
273
- response = await AsyncHttpRequest ((await self .session ()).post , url = url , json = request_payload ).make ()
273
+ response = await AsyncHttpRequest (
274
+ (await self .session ()).post , url = url , json = request_payload , name = "start_launch"
275
+ ).make ()
274
276
if not response :
275
277
return None
276
278
@@ -345,11 +347,13 @@ async def start_test_item(
345
347
uuid = uuid ,
346
348
).payload
347
349
348
- response = await AsyncHttpRequest ((await self .session ()).post , url = url , json = request_payload ).make ()
350
+ response = await AsyncHttpRequest (
351
+ (await self .session ()).post , url = url , json = request_payload , name = "start_test_item"
352
+ ).make ()
349
353
if not response :
350
354
return None
351
355
item_id = await response .id
352
- if item_id is NOT_FOUND or item_id is None :
356
+ if not item_id :
353
357
logger .warning ("start_test_item - invalid response: %s" , str (await response .json ))
354
358
else :
355
359
logger .debug ("start_test_item - ID: %s" , item_id )
@@ -400,7 +404,9 @@ async def finish_test_item(
400
404
retry = retry ,
401
405
retry_of = retry_of ,
402
406
).payload
403
- response = await AsyncHttpRequest ((await self .session ()).put , url = url , json = request_payload ).make ()
407
+ response = await AsyncHttpRequest (
408
+ (await self .session ()).put , url = url , json = request_payload , name = "finish_test_item"
409
+ ).make ()
404
410
if not response :
405
411
return None
406
412
message = await response .message
@@ -434,7 +440,7 @@ async def finish_launch(
434
440
description = kwargs .get ("description" ),
435
441
).payload
436
442
response = await AsyncHttpRequest (
437
- (await self .session ()).put , url = url , json = request_payload , name = "Finish Launch "
443
+ (await self .session ()).put , url = url , json = request_payload , name = "finish_launch "
438
444
).make ()
439
445
if not response :
440
446
return None
@@ -463,15 +469,17 @@ async def update_test_item(
463
469
}
464
470
item_id = await self .get_item_id_by_uuid (item_uuid )
465
471
url = root_uri_join (self .base_url_v1 , "item" , item_id , "update" )
466
- response = await AsyncHttpRequest ((await self .session ()).put , url = url , json = data ).make ()
472
+ response = await AsyncHttpRequest (
473
+ (await self .session ()).put , url = url , json = data , name = "update_test_item"
474
+ ).make ()
467
475
if not response :
468
476
return None
469
477
logger .debug ("update_test_item - Item: %s" , item_id )
470
478
return await response .message
471
479
472
480
async def __get_launch_uuid_url (self , launch_uuid_future : Union [str , Task [str ]]) -> Optional [str ]:
473
481
launch_uuid = await await_if_necessary (launch_uuid_future )
474
- if launch_uuid is NOT_FOUND or launch_uuid is None :
482
+ if not launch_uuid :
475
483
logger .warning ("Attempt to make request for non-existent Launch UUID." )
476
484
return None
477
485
logger .debug ("get_launch_info - ID: %s" , launch_uuid )
@@ -484,7 +492,7 @@ async def get_launch_info(self, launch_uuid_future: Union[str, Task[str]]) -> Op
484
492
:return: Launch information in dictionary.
485
493
"""
486
494
url = self .__get_launch_uuid_url (launch_uuid_future )
487
- response = await AsyncHttpRequest ((await self .session ()).get , url = url ).make ()
495
+ response = await AsyncHttpRequest ((await self .session ()).get , url = url , name = "get_launch_info" ).make ()
488
496
if not response :
489
497
return None
490
498
launch_info = None
@@ -497,7 +505,7 @@ async def get_launch_info(self, launch_uuid_future: Union[str, Task[str]]) -> Op
497
505
498
506
async def __get_item_uuid_url (self , item_uuid_future : Union [Optional [str ], Task [Optional [str ]]]) -> Optional [str ]:
499
507
item_uuid = await await_if_necessary (item_uuid_future )
500
- if item_uuid is NOT_FOUND or item_uuid is None :
508
+ if not item_uuid :
501
509
logger .warning ("Attempt to make request for non-existent UUID." )
502
510
return None
503
511
return root_uri_join (self .base_url_v1 , "item" , "uuid" , item_uuid )
@@ -509,7 +517,7 @@ async def get_item_id_by_uuid(self, item_uuid_future: Union[str, Task[str]]) ->
509
517
:return: Test Item ID.
510
518
"""
511
519
url = self .__get_item_uuid_url (item_uuid_future )
512
- response = await AsyncHttpRequest ((await self .session ()).get , url = url ).make ()
520
+ response = await AsyncHttpRequest ((await self .session ()).get , url = url , name = "get_item_id" ).make ()
513
521
return await response .id if response else None
514
522
515
523
async def get_launch_ui_id (self , launch_uuid_future : Union [str , Task [str ]]) -> Optional [int ]:
@@ -549,7 +557,7 @@ async def get_project_settings(self) -> Optional[dict]:
549
557
:return: Settings response in Dictionary.
550
558
"""
551
559
url = root_uri_join (self .base_url_v1 , "settings" )
552
- response = await AsyncHttpRequest ((await self .session ()).get , url = url ).make ()
560
+ response = await AsyncHttpRequest ((await self .session ()).get , url = url , name = "get_project_settings" ).make ()
553
561
return await response .json if response else None
554
562
555
563
async def log_batch (self , log_batch : Optional [List [AsyncRPRequestLog ]]) -> Optional [Tuple [str , ...]]:
@@ -561,7 +569,7 @@ async def log_batch(self, log_batch: Optional[List[AsyncRPRequestLog]]) -> Optio
561
569
url = root_uri_join (self .base_url_v2 , "log" )
562
570
if log_batch :
563
571
response = await AsyncHttpRequest (
564
- (await self .session ()).post , url = url , data = AsyncRPLogBatch (log_batch ).payload
572
+ (await self .session ()).post , url = url , data = AsyncRPLogBatch (log_batch ).payload , name = "log"
565
573
).make ()
566
574
if not response :
567
575
return None
@@ -639,8 +647,6 @@ def launch_uuid(self) -> Optional[str]:
639
647
640
648
:return: UUID string.
641
649
"""
642
- if self .__launch_uuid is NOT_FOUND :
643
- return None
644
650
return self .__launch_uuid
645
651
646
652
@property
@@ -809,9 +815,10 @@ async def start_test_item(
809
815
uuid = uuid ,
810
816
** kwargs ,
811
817
)
812
- if item_id and item_id is not NOT_FOUND :
813
- logger .debug ("start_test_item - ID: %s" , item_id )
814
- self ._add_current_item (item_id )
818
+ if not item_id :
819
+ return None
820
+ logger .debug ("start_test_item - ID: %s" , item_id )
821
+ self ._add_current_item (item_id )
815
822
return item_id
816
823
817
824
async def finish_test_item (
@@ -972,9 +979,6 @@ async def log(
972
979
:param item_id: UUID of the ReportPortal Item the message belongs to.
973
980
:return: Response message Tuple if Log message batch was sent or None.
974
981
"""
975
- if item_id is NOT_FOUND :
976
- logger .warning ("Attempt to log to non-existent item" )
977
- return None
978
982
rp_file = RPFile (** attachment ) if attachment else None
979
983
rp_log = AsyncRPRequestLog (self .__launch_uuid , time , rp_file , item_id , level , message )
980
984
return await self .__client .log_batch (await self ._log_batcher .append_async (rp_log ))
0 commit comments