Skip to content

Commit

Permalink
Merge pull request #224 from reportportal/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
HardNorth committed Oct 18, 2023
2 parents bdd4bfc + ec8a070 commit 883d2f1
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 23 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## [Unreleased]
### Fixed
- Python 3.7 support, by @HardNorth
- Launch UUID attribute for AIO clients, by @HardNorth
- Http timeout bypass for Sync Client, by @HardNorth

## [5.5.2]
### Fixed
- Attribute truncation for every method with attributes, by @HardNorth

## [5.5.1]
Expand Down
6 changes: 3 additions & 3 deletions reportportal_client/aio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ async def start_launch(self,

if not self._skip_analytics:
stat_coro = async_send_event('start_launch', *agent_name_version(attributes))
self.__stat_task = asyncio.create_task(stat_coro, name='Statistics update')
self.__stat_task = asyncio.create_task(stat_coro)

launch_uuid = await response.id
logger.debug(f'start_launch - ID: {launch_uuid}')
Expand Down Expand Up @@ -675,8 +675,8 @@ def __init__(
self.__client = client
else:
self.__client = Client(endpoint, project, **kwargs)
self.__launch_uuid = launch_uuid
if launch_uuid:
self.__launch_uuid = launch_uuid
self.use_own_launch = False
else:
self.use_own_launch = True
Expand Down Expand Up @@ -1040,8 +1040,8 @@ def __init__(
self.__client = Client(endpoint, project, **kwargs)
self.own_client = False

self.__launch_uuid = launch_uuid
if launch_uuid:
self.__launch_uuid = launch_uuid
self.own_launch = False
else:
self.own_launch = True
Expand Down
36 changes: 17 additions & 19 deletions reportportal_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,8 @@ def start_launch(self,
rerun=rerun,
rerun_of=rerun_of
).payload
response = HttpRequest(self.session.post, url=url, json=request_payload,
verify_ssl=self.verify_ssl).make()
response = HttpRequest(self.session.post, url=url, json=request_payload, verify_ssl=self.verify_ssl,
http_timeout=self.http_timeout).make()
if not response:
return

Expand Down Expand Up @@ -614,10 +614,8 @@ def start_test_item(self,
test_case_id=test_case_id
).payload

response = HttpRequest(self.session.post,
url=url,
json=request_payload,
verify_ssl=self.verify_ssl).make()
response = HttpRequest(self.session.post, url=url, json=request_payload, verify_ssl=self.verify_ssl,
http_timeout=self.http_timeout).make()
if not response:
return
item_id = response.id
Expand Down Expand Up @@ -665,8 +663,8 @@ def finish_test_item(self,
issue=issue,
retry=retry
).payload
response = HttpRequest(self.session.put, url=url, json=request_payload,
verify_ssl=self.verify_ssl).make()
response = HttpRequest(self.session.put, url=url, json=request_payload, verify_ssl=self.verify_ssl,
http_timeout=self.http_timeout).make()
if not response:
return
self._remove_current_item()
Expand Down Expand Up @@ -699,8 +697,8 @@ def finish_launch(self,
description=kwargs.get('description')
).payload
response = HttpRequest(self.session.put, url=url, json=request_payload,
verify_ssl=self.verify_ssl,
name='Finish Launch').make()
verify_ssl=self.verify_ssl, name='Finish Launch',
http_timeout=self.http_timeout).make()
if not response:
return
logger.debug('finish_launch - ID: %s', self.launch_uuid)
Expand All @@ -726,8 +724,8 @@ def update_test_item(self, item_uuid: str, attributes: Optional[Union[list, dict
}
item_id = self.get_item_id_by_uuid(item_uuid)
url = uri_join(self.base_url_v1, 'item', item_id, 'update')
response = HttpRequest(self.session.put, url=url, json=data,
verify_ssl=self.verify_ssl).make()
response = HttpRequest(self.session.put, url=url, json=data, verify_ssl=self.verify_ssl,
http_timeout=self.http_timeout).make()
if not response:
return
logger.debug('update_test_item - Item: %s', item_id)
Expand All @@ -737,7 +735,7 @@ def _log(self, batch: Optional[List[RPRequestLog]]) -> Optional[Tuple[str, ...]]
if batch:
url = uri_join(self.base_url_v2, 'log')
response = HttpRequest(self.session.post, url, files=RPLogBatch(batch).payload,
verify_ssl=self.verify_ssl).make()
verify_ssl=self.verify_ssl, http_timeout=self.http_timeout).make()
return response.messages

def log(self,
Expand Down Expand Up @@ -772,8 +770,8 @@ def get_item_id_by_uuid(self, item_uuid: str) -> Optional[str]:
:return: Test Item ID.
"""
url = uri_join(self.base_url_v1, 'item', 'uuid', item_uuid)
response = HttpRequest(self.session.get, url=url,
verify_ssl=self.verify_ssl).make()
response = HttpRequest(self.session.get, url=url, verify_ssl=self.verify_ssl,
http_timeout=self.http_timeout).make()
return response.id if response else None

def get_launch_info(self) -> Optional[dict]:
Expand All @@ -785,8 +783,8 @@ def get_launch_info(self) -> Optional[dict]:
return {}
url = uri_join(self.base_url_v1, 'launch', 'uuid', self.launch_uuid)
logger.debug('get_launch_info - ID: %s', self.launch_uuid)
response = HttpRequest(self.session.get, url=url,
verify_ssl=self.verify_ssl).make()
response = HttpRequest(self.session.get, url=url, verify_ssl=self.verify_ssl,
http_timeout=self.http_timeout).make()
if not response:
return
launch_info = None
Expand Down Expand Up @@ -835,8 +833,8 @@ def get_project_settings(self) -> Optional[dict]:
:return: Settings response in Dictionary.
"""
url = uri_join(self.base_url_v1, 'settings')
response = HttpRequest(self.session.get, url=url,
verify_ssl=self.verify_ssl).make()
response = HttpRequest(self.session.get, url=url, verify_ssl=self.verify_ssl,
http_timeout=self.http_timeout).make()
return response.json if response else None

def _add_current_item(self, item: str) -> None:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from setuptools import setup, find_packages

__version__ = '5.5.2'
__version__ = '5.5.3'

TYPE_STUBS = ['*.pyi']

Expand Down
32 changes: 32 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,35 @@ def test_attribute_truncation(rp_client: RPClient, method, call_method, argument
assert 'attributes' in kwargs['json']
assert kwargs['json']['attributes']
assert len(kwargs['json']['attributes'][0]['value']) == 128


@pytest.mark.parametrize(
'method, call_method, arguments',
[
('start_launch', 'post', ['Test Launch', timestamp()]),
('start_test_item', 'post', ['Test Item', timestamp(), 'SUITE']),
('finish_test_item', 'put', ['test_item_uuid', timestamp()]),
('finish_launch', 'put', [timestamp()]),
('update_test_item', 'put', ['test_item_uuid']),
('get_launch_info', 'get', []),
('get_project_settings', 'get', []),
('get_item_id_by_uuid', 'get', ['test_item_uuid']),
('log', 'post', [timestamp(), 'Test Message']),
]
)
def test_http_timeout_bypass(method, call_method, arguments):
http_timeout = (35.1, 33.3)
rp_client = RPClient('http://endpoint', 'project', 'api_key',
http_timeout=http_timeout, log_batch_size=1)
session: mock.Mock = mock.Mock()
rp_client.session = session
rp_client._skip_analytics = True

if method != 'start_launch':
rp_client._RPClient__launch_uuid = 'test_launch_id'

getattr(rp_client, method)(*arguments)
getattr(session, call_method).assert_called_once()
kwargs = getattr(session, call_method).call_args_list[0][1]
assert 'timeout' in kwargs
assert kwargs['timeout'] == http_timeout

0 comments on commit 883d2f1

Please sign in to comment.