diff --git a/CHANGELOG.md b/CHANGELOG.md index 71e542f..e31d5f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] diff --git a/reportportal_client/aio/client.py b/reportportal_client/aio/client.py index 3fab8cb..800e024 100644 --- a/reportportal_client/aio/client.py +++ b/reportportal_client/aio/client.py @@ -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}') @@ -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 @@ -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 diff --git a/reportportal_client/client.py b/reportportal_client/client.py index 8ea109d..64206ee 100644 --- a/reportportal_client/client.py +++ b/reportportal_client/client.py @@ -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 @@ -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 @@ -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() @@ -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) @@ -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) @@ -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, @@ -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]: @@ -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 @@ -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: diff --git a/setup.py b/setup.py index 3e4dee9..2098980 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup, find_packages -__version__ = '5.5.2' +__version__ = '5.5.3' TYPE_STUBS = ['*.pyi'] diff --git a/tests/test_client.py b/tests/test_client.py index 83a0ab0..5345534 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -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