From b7bdbf0156247a5831925b46457e713e6dd19e90 Mon Sep 17 00:00:00 2001 From: "reportportal.io" Date: Thu, 23 Jun 2022 14:37:59 +0000 Subject: [PATCH 01/18] Changelog update --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75dbd296..af197c34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog ## [Unreleased] + +## [5.2.3] ### Added - Ability to pass client instance in `RPLogHandler` constructor, by @HardNorth - Issue [#179](https://github.com/reportportal/client-Python/issues/179): batch logging request payload size tracking, by @HardNorth From 189a2010d781538604bf61b08a900e8d80444fc2 Mon Sep 17 00:00:00 2001 From: "reportportal.io" Date: Thu, 23 Jun 2022 14:38:00 +0000 Subject: [PATCH 02/18] Version update --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e1c4d229..c00a6429 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages -__version__ = '5.2.3' +__version__ = '5.2.4' with open('requirements.txt') as f: requirements = f.read().splitlines() From e06ff2dfaf0c5177e6099f7d73b2d58dc0651b5c Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Thu, 23 Jun 2022 17:41:11 +0300 Subject: [PATCH 03/18] Do not test on push to 'master' --- .github/workflows/tests.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a8527eaf..0c7271dd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,6 +1,14 @@ name: Tests -on: [push, pull_request] +on: + push: + branches: + - '*' + - '!master' + pull_request: + branches: + - 'master' + - 'develop' jobs: build: From 403a61274df52478931933d9608c858e8b451b18 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Tue, 28 Jun 2022 15:46:38 +0300 Subject: [PATCH 04/18] Pydoc correction --- reportportal_client/logs/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reportportal_client/logs/__init__.py b/reportportal_client/logs/__init__.py index 6bb25705..b541bdab 100644 --- a/reportportal_client/logs/__init__.py +++ b/reportportal_client/logs/__init__.py @@ -107,7 +107,8 @@ def __init__(self, level=logging.NOTSET, filter_client_logs=False, :param filter_client_logs: if True throw away logs emitted by a ReportPortal client :param endpoint: Report Portal endpoint URL, used to filter - out urllib3 logs, mutes Report Portal HTTP logs if set + out urllib3 logs, mutes Report Portal HTTP logs if set, optional + parameter :param ignored_record_names: a tuple of record names which will be filtered out by the handler (with startswith method) """ From 85b188429a38af6a54b40173325b4a3ab30971e9 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Tue, 28 Jun 2022 15:53:55 +0300 Subject: [PATCH 05/18] Quote correction --- reportportal_client/helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reportportal_client/helpers.py b/reportportal_client/helpers.py index e66e9829..b52e87c8 100644 --- a/reportportal_client/helpers.py +++ b/reportportal_client/helpers.py @@ -205,11 +205,11 @@ def get_function_params(func, args, kwargs): TYPICAL_MULTIPART_FOOTER_LENGTH = len(TYPICAL_MULTIPART_FOOTER) -TYPICAL_JSON_ARRAY = "[]" +TYPICAL_JSON_ARRAY = '[]' TYPICAL_JSON_ARRAY_LENGTH = len(TYPICAL_JSON_ARRAY) -TYPICAL_JSON_ARRAY_ELEMENT = "," +TYPICAL_JSON_ARRAY_ELEMENT = ',' TYPICAL_JSON_ARRAY_ELEMENT_LENGTH = len(TYPICAL_JSON_ARRAY_ELEMENT) From e7ff30a0fe03cec201c22572cc6351c218870db1 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Tue, 28 Jun 2022 15:54:27 +0300 Subject: [PATCH 06/18] Quote correction --- reportportal_client/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reportportal_client/helpers.py b/reportportal_client/helpers.py index b52e87c8..2064e9d2 100644 --- a/reportportal_client/helpers.py +++ b/reportportal_client/helpers.py @@ -172,7 +172,7 @@ def get_function_params(func, args, kwargs): # Use deprecated method for python 2.7 compatibility, it's still here for # Python 3.10.2, so it's completely redundant to show the warning with warnings.catch_warnings(): - warnings.filterwarnings("ignore", category=DeprecationWarning) + warnings.filterwarnings('ignore', category=DeprecationWarning) # noinspection PyDeprecation arg_spec = inspect.getargspec(func) result = dict() From 6b90bdbc96281a3f93256fa037886827d7acbd89 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Tue, 28 Jun 2022 19:50:49 +0300 Subject: [PATCH 07/18] Minor lock correction --- reportportal_client/core/log_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reportportal_client/core/log_manager.py b/reportportal_client/core/log_manager.py index 2199a158..78e15ded 100644 --- a/reportportal_client/core/log_manager.py +++ b/reportportal_client/core/log_manager.py @@ -88,8 +88,8 @@ def _log_process(self, log_req): :param log_req: RPRequestLog object """ + rq_size = log_req.multipart_size with self._lock: - rq_size = log_req.multipart_size if self._payload_size + rq_size >= self.max_payload_size: if len(self._batch) > 0: self._send_batch() From e365f57f510dc42f6314fc4b93e0a981a25f2597 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Mon, 11 Jul 2022 19:33:19 +0300 Subject: [PATCH 08/18] LogManager class moved from core package to logs --- CHANGELOG.md | 2 ++ reportportal_client/client.py | 2 +- reportportal_client/client.pyi | 2 +- reportportal_client/{core => logs}/log_manager.py | 0 reportportal_client/{core => logs}/log_manager.pyi | 0 tests/logs/__init__.py | 14 ++++++++++++++ tests/logs/test_log_manager.py | 2 +- 7 files changed, 19 insertions(+), 3 deletions(-) rename reportportal_client/{core => logs}/log_manager.py (100%) rename reportportal_client/{core => logs}/log_manager.pyi (100%) create mode 100644 tests/logs/__init__.py diff --git a/CHANGELOG.md b/CHANGELOG.md index af197c34..19c38741 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog ## [Unreleased] +### Changed +- `LogManager` class moved from `core` package to `logs` package ## [5.2.3] ### Added diff --git a/reportportal_client/client.py b/reportportal_client/client.py index f7e5a226..07c1a56a 100644 --- a/reportportal_client/client.py +++ b/reportportal_client/client.py @@ -20,7 +20,7 @@ from requests.adapters import HTTPAdapter, Retry from ._local import set_current -from .core.log_manager import LogManager, MAX_LOG_BATCH_PAYLOAD_SIZE +from .logs.log_manager import LogManager, MAX_LOG_BATCH_PAYLOAD_SIZE from .core.rp_requests import ( HttpRequest, ItemStartRequest, diff --git a/reportportal_client/client.pyi b/reportportal_client/client.pyi index 56ee5669..b4e6103e 100644 --- a/reportportal_client/client.pyi +++ b/reportportal_client/client.pyi @@ -2,7 +2,7 @@ from typing import Any, Dict, List, Optional, Text, Tuple, Union from requests import Session -from reportportal_client.core.log_manager import LogManager as LogManager +from reportportal_client.logs.log_manager import LogManager as LogManager from reportportal_client.core.rp_issues import Issue as Issue from reportportal_client.steps import StepReporter diff --git a/reportportal_client/core/log_manager.py b/reportportal_client/logs/log_manager.py similarity index 100% rename from reportportal_client/core/log_manager.py rename to reportportal_client/logs/log_manager.py diff --git a/reportportal_client/core/log_manager.pyi b/reportportal_client/logs/log_manager.pyi similarity index 100% rename from reportportal_client/core/log_manager.pyi rename to reportportal_client/logs/log_manager.pyi diff --git a/tests/logs/__init__.py b/tests/logs/__init__.py new file mode 100644 index 00000000..c72fbd80 --- /dev/null +++ b/tests/logs/__init__.py @@ -0,0 +1,14 @@ +"""This package contains unit tests for logging.""" + +# Copyright (c) 2022 EPAM Systems +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License diff --git a/tests/logs/test_log_manager.py b/tests/logs/test_log_manager.py index 0a5b6c3b..d3f4a2d7 100644 --- a/tests/logs/test_log_manager.py +++ b/tests/logs/test_log_manager.py @@ -16,7 +16,7 @@ from six.moves import mock from reportportal_client import helpers -from reportportal_client.core.log_manager import LogManager, \ +from reportportal_client.logs.log_manager import LogManager, \ MAX_LOG_BATCH_PAYLOAD_SIZE RP_URL = 'http://docker.local:8080' From 77f17c788d8c9f434204cfd603f59de60e746ca7 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Mon, 11 Jul 2022 21:40:26 +0300 Subject: [PATCH 09/18] Copyright add --- tests/test_helpers.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/test_helpers.py b/tests/test_helpers.py index 02beec42..80748428 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -1,4 +1,18 @@ -"""This modules contains unit tests for the helpers module.""" +"""This script contains unit tests for the helpers script.""" + +# Copyright (c) 2022 EPAM Systems +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License + from six.moves import mock from reportportal_client.helpers import ( From be07d32cf055e1732bf1389f107d8925ecca15d5 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Mon, 11 Jul 2022 21:41:05 +0300 Subject: [PATCH 10/18] Logging continuation test add --- reportportal_client/core/worker.py | 20 ++++----- reportportal_client/core/worker.pyi | 4 +- tests/core/__init__.py | 14 ++++++ tests/core/test_worker.py | 70 +++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 12 deletions(-) create mode 100644 tests/core/__init__.py create mode 100644 tests/core/test_worker.py diff --git a/reportportal_client/core/worker.py b/reportportal_client/core/worker.py index bca25775..92acdf04 100644 --- a/reportportal_client/core/worker.py +++ b/reportportal_client/core/worker.py @@ -87,6 +87,16 @@ def _command_process(self, cmd): else: self._stop() + def _request_process(self, request): + """Send request to RP and update response attribute of the request.""" + logger.debug('[%s] Processing {%s} request', self.name, request) + try: + request.response = request.http_request.make() + except Exception as err: + logger.exception('[%s] Unknown exception has occurred. ' + 'Skipping it.', err) + self._queue.task_done() + def _monitor(self): """Monitor worker queues and process them. @@ -111,16 +121,6 @@ def _monitor(self): logger.debug('[%s] Received {%s} request', self.name, cmd) self._request_process(cmd) - def _request_process(self, request): - """Send request to RP and update response attribute of the request.""" - logger.debug('[%s] Processing {%s} request', self.name, request) - try: - request.response = request.http_request.make() - except Exception as err: - logger.exception('[%s] Unknown exception has occurred. Terminating' - ' the worker.', err) - self._queue.task_done() - def _stop(self): """Routine that stops the worker thread(s). diff --git a/reportportal_client/core/worker.pyi b/reportportal_client/core/worker.pyi index 7ddb06ac..ad0c9a3e 100644 --- a/reportportal_client/core/worker.pyi +++ b/reportportal_client/core/worker.pyi @@ -53,10 +53,10 @@ class APIWorker: def _command_process(self, cmd: Optional[ControlCommand]) -> None: ... - def _monitor(self) -> None: ... - def _request_process(self, request: Optional[RPRequest]) -> None: ... + def _monitor(self) -> None: ... + def _stop(self) -> None: ... def _stop_immediately(self) -> None: ... diff --git a/tests/core/__init__.py b/tests/core/__init__.py new file mode 100644 index 00000000..30e3faf9 --- /dev/null +++ b/tests/core/__init__.py @@ -0,0 +1,14 @@ +"""This package contains unit tests for core module.""" + +# Copyright (c) 2022 EPAM Systems +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License diff --git a/tests/core/test_worker.py b/tests/core/test_worker.py new file mode 100644 index 00000000..30d4024b --- /dev/null +++ b/tests/core/test_worker.py @@ -0,0 +1,70 @@ +"""Worker class tests.""" + +# Copyright (c) 2022 EPAM Systems +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License + +import time +from six.moves import queue, mock + +from requests.exceptions import ConnectionError +from reportportal_client.core.rp_requests import ( + HttpRequest, + RPLogBatch, + RPRequestLog +) +from reportportal_client.core.worker import APIWorker +from reportportal_client.helpers import timestamp + +LOG_REQUEST_URL = 'http://docker.local:8080/api/v1/default_personal/log' +TEST_LAUNCH_UUID = 'test_uuid' +TEST_MASSAGE = "test message" + + +def test_worker_continue_working_on_request_error(): + test_queue = queue.PriorityQueue() + worker = APIWorker(test_queue) + worker.start() + + log_request = RPRequestLog(TEST_LAUNCH_UUID, timestamp(), + message=TEST_MASSAGE) + log_batch = RPLogBatch([log_request]) + + fail_session = mock.Mock() + fail_session.side_effect = Exception() + http_fail = HttpRequest( + fail_session, LOG_REQUEST_URL, files=log_batch.payload, + verify_ssl=False) + log_batch.http_request = http_fail + worker.send(log_batch) + + start_time = time.time() + while fail_session.call_count < 1 and time.time() - start_time < 10: + time.sleep(0.1) + + assert fail_session.call_count == 1 + assert log_batch.response is None + + pass_session = mock.Mock() + http_pass = HttpRequest( + pass_session, LOG_REQUEST_URL, files=log_batch.payload, + verify_ssl=False) + log_batch.http_request = http_pass + worker.send(log_batch) + + start_time = time.time() + while pass_session.call_count < 1 and time.time() - start_time < 10: + time.sleep(0.1) + + assert pass_session.call_count == 1 + assert log_batch.response + worker.stop() From 449071cb3faf420f2609eb934096c649f7bb09aa Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Mon, 11 Jul 2022 21:44:44 +0300 Subject: [PATCH 11/18] Build fix --- tests/core/test_worker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core/test_worker.py b/tests/core/test_worker.py index 30d4024b..27109c2c 100644 --- a/tests/core/test_worker.py +++ b/tests/core/test_worker.py @@ -14,9 +14,9 @@ # limitations under the License import time + from six.moves import queue, mock -from requests.exceptions import ConnectionError from reportportal_client.core.rp_requests import ( HttpRequest, RPLogBatch, From 528b514be164bd06ad6e0909d3b41e8e3c91ab76 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Mon, 11 Jul 2022 21:49:44 +0300 Subject: [PATCH 12/18] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 357c6b0c..a4f638b7 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,9 @@ [![Python versions](https://img.shields.io/pypi/pyversions/reportportal-client.svg)](https://pypi.org/project/reportportal-client) [![Build Status](https://github.com/reportportal/client-Python/actions/workflows/tests.yml/badge.svg)](https://github.com/reportportal/client-Python/actions/workflows/tests.yml) [![codecov.io](https://codecov.io/gh/reportportal/client-Python/branch/master/graph/badge.svg)](https://codecov.io/gh/reportportal/client-Python) +[![Join Slack chat!](https://reportportal-slack-auto.herokuapp.com/badge.svg)](https://reportportal-slack-auto.herokuapp.com) +[![stackoverflow](https://img.shields.io/badge/reportportal-stackoverflow-orange.svg?style=flat)](http://stackoverflow.com/questions/tagged/reportportal) +[![Build with Love](https://img.shields.io/badge/build%20with-❤%EF%B8%8F%E2%80%8D-lightgrey.svg)](http://reportportal.io?style=flat) Library used only for implementors of custom listeners for ReportPortal From 993ff177d77512b38126281cd48fab9ea8e341e3 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Thu, 15 Sep 2022 17:14:21 +0300 Subject: [PATCH 13/18] Action version update --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 650dca55..459ab20d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: - uses: actions/checkout@v2 - name: Generate versions - uses: HardNorth/github-version-generate@v1.1.2 + uses: HardNorth/github-version-generate@v1.2.0 with: version-source: file version-file: ${{ env.VERSION_FILE }} From 57fb0d58540d28d0eafed5ba1875d970009c97d6 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Thu, 15 Sep 2022 17:16:27 +0300 Subject: [PATCH 14/18] Issue #192 fix --- CHANGELOG.md | 4 +++- reportportal_client/client.py | 31 +++++++++++++++++++++++++------ reportportal_client/client.pyi | 1 + tests/test_client.py | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19c38741..6d001e30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,9 @@ ## [Unreleased] ### Changed -- `LogManager` class moved from `core` package to `logs` package +- `LogManager` class moved from `core` package to `logs` package, by @HardNorth +### Fixed +- Issue [#192](https://github.com/reportportal/client-Python/issues/192): launch URL generation, by @HardNorth ## [5.2.3] ### Added diff --git a/reportportal_client/client.py b/reportportal_client/client.py index 07c1a56a..3306d3bf 100644 --- a/reportportal_client/client.py +++ b/reportportal_client/client.py @@ -20,7 +20,6 @@ from requests.adapters import HTTPAdapter, Retry from ._local import set_current -from .logs.log_manager import LogManager, MAX_LOG_BATCH_PAYLOAD_SIZE from .core.rp_requests import ( HttpRequest, ItemStartRequest, @@ -29,6 +28,7 @@ LaunchFinishRequest ) from .helpers import uri_join, verify_value_length +from .logs.log_manager import LogManager, MAX_LOG_BATCH_PAYLOAD_SIZE from .static.defines import NOT_FOUND from .steps import StepReporter @@ -59,6 +59,7 @@ def __init__(self, launch_id=None, http_timeout=(10, 10), log_batch_payload_size=MAX_LOG_BATCH_PAYLOAD_SIZE, + mode='DEFAULT', **_): """Initialize required attributes. @@ -100,6 +101,7 @@ def __init__(self, self.session = requests.Session() self.step_reporter = StepReporter(self) self._item_stack = [] + self.mode = mode if retries: retry_strategy = Retry( total=retries, @@ -244,10 +246,19 @@ def get_launch_ui_url(self): :return: launch URL or all launches URL. """ - ui_id = self.get_launch_ui_id() + launch_info = self.get_launch_info() + ui_id = launch_info.get('id') if launch_info else None if not ui_id: return - path = 'ui/#{0}/launches/all/{1}'.format(self.project, ui_id) + mode = launch_info.get('mode') if launch_info else None + if not mode: + mode = self.mode + + launch_type = "launches" if mode.upper() == 'DEFAULT' else 'userdebug' + + path = 'ui/#{project_name}/{launch_type}/all/{launch_id}'.format( + project_name=self.project.lower(), launch_type=launch_type, + launch_id=ui_id) url = uri_join(self.endpoint, path) logger.debug('get_launch_ui_url - ID: %s', self.launch_id) return url @@ -282,7 +293,6 @@ def start_launch(self, start_time, description=None, attributes=None, - mode=None, rerun=False, rerun_of=None, **kwargs): @@ -292,12 +302,21 @@ def start_launch(self, :param start_time: Launch start time :param description: Launch description :param attributes: Launch attributes - :param mode: Launch mode :param rerun: Enables launch rerun mode :param rerun_of: Rerun mode. Specifies launch to be re-runned. Should be used with the 'rerun' option. """ url = uri_join(self.base_url_v2, 'launch') + + # We are moving 'mode' param to the constructor, next code for the + # transition period only. + my_kwargs = dict(kwargs) + mode = my_kwargs.get('mode') + if not mode: + mode = self.mode + else: + del my_kwargs['mode'] + request_payload = LaunchStartRequest( name=name, start_time=start_time, @@ -306,7 +325,7 @@ def start_launch(self, mode=mode, rerun=rerun, rerun_of=rerun_of or kwargs.get('rerunOf'), - **kwargs + **my_kwargs ).payload response = HttpRequest(self.session.post, url=url, diff --git a/reportportal_client/client.pyi b/reportportal_client/client.pyi index b4e6103e..b7711e1f 100644 --- a/reportportal_client/client.pyi +++ b/reportportal_client/client.pyi @@ -27,6 +27,7 @@ class RPClient: http_timeout: Union[float, Tuple[float, float]] = ... session: Session = ... step_reporter: StepReporter = ... + mode: str = ... def __init__( self, diff --git a/tests/test_client.py b/tests/test_client.py index 24833d58..08fc6c37 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -14,6 +14,7 @@ import pytest from requests import Response from requests.exceptions import ReadTimeout +from six.moves import mock from reportportal_client.helpers import timestamp from reportportal_client.static.defines import NOT_FOUND @@ -56,3 +57,35 @@ def test_connection_errors(rp_client, requests_method, client_method, getattr(rp_client.session, requests_method).side_effect = response_error result = getattr(rp_client, client_method)(*client_params) assert result == expected_result + + +LAUNCH_ID = 333 +EXPECTED_DEFAULT_URL = 'http://endpoint/ui/#project/launches/all/' + str( + LAUNCH_ID) +EXPECTED_DEBUG_URL = 'http://endpoint/ui/#project/userdebug/all/' + str( + LAUNCH_ID) + + +@pytest.mark.parametrize( + 'launch_mode, project_name, expected_url', + [ + ('DEFAULT', "project", EXPECTED_DEFAULT_URL), + ('DEBUG', "project", EXPECTED_DEBUG_URL), + ('DEFAULT', "PROJECT", EXPECTED_DEFAULT_URL), + ('debug', "PROJECT", EXPECTED_DEBUG_URL) + ] +) +def test_launch_url_get(rp_client, launch_mode, project_name, expected_url): + rp_client.launch_id = 'test_launch_id' + rp_client.project = project_name + + response = mock.Mock() + response.is_success = True + response.json.side_effect = lambda: {'mode': launch_mode, 'id': LAUNCH_ID} + + def get_call(*args, **kwargs): + return response + + rp_client.session.get.side_effect = get_call + + assert rp_client.get_launch_ui_url() == expected_url From 7e114bb954c1131ec9dcdfcbdeeeadcad45b32bf Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Thu, 15 Sep 2022 17:44:07 +0300 Subject: [PATCH 15/18] Bump major version due to API update --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c00a6429..b01453e5 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages -__version__ = '5.2.4' +__version__ = '5.3.0' with open('requirements.txt') as f: requirements = f.read().splitlines() From 6de4f525385c36effc09f2e171fc4f0360f08461 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Thu, 15 Sep 2022 19:10:41 +0300 Subject: [PATCH 16/18] Add `core.log_manager` deprecation --- reportportal_client/__init__.py | 4 +-- reportportal_client/client.py | 1 - reportportal_client/core/__init__.py | 6 +++++ reportportal_client/core/log_manager.py | 35 +++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 reportportal_client/core/log_manager.py diff --git a/reportportal_client/__init__.py b/reportportal_client/__init__.py index e9a426ff..ff19c8d0 100644 --- a/reportportal_client/__init__.py +++ b/reportportal_client/__init__.py @@ -21,8 +21,8 @@ __all__ = [ 'current', - "RPLogger", - "RPLogHandler", + 'RPLogger', + 'RPLogHandler', 'ReportPortalService', 'step', ] diff --git a/reportportal_client/client.py b/reportportal_client/client.py index 3306d3bf..ed813133 100644 --- a/reportportal_client/client.py +++ b/reportportal_client/client.py @@ -15,7 +15,6 @@ limitations under the License. """ import logging - import requests from requests.adapters import HTTPAdapter, Retry diff --git a/reportportal_client/core/__init__.py b/reportportal_client/core/__init__.py index 78e27ba6..6df40acc 100644 --- a/reportportal_client/core/__init__.py +++ b/reportportal_client/core/__init__.py @@ -12,3 +12,9 @@ # limitations under the License """This package contains core reportportal-client modules.""" + +from reportportal_client.logs import log_manager + +__all__ = [ + 'log_manager' +] diff --git a/reportportal_client/core/log_manager.py b/reportportal_client/core/log_manager.py new file mode 100644 index 00000000..aa1fe8dd --- /dev/null +++ b/reportportal_client/core/log_manager.py @@ -0,0 +1,35 @@ +# Copyright (c) 2022 EPAM Systems +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License + +""" +.. deprecated:: 5.2.4 + Use `logs.log_manager` instead. +""" + +import warnings + +from reportportal_client.logs.log_manager import LogManager, \ + MAX_LOG_BATCH_PAYLOAD_SIZE + +warnings.warn( + message="`core.log_manager` is deprecated since 5.2.4 and will be subject " + "for removing in the next major version. Use logs.log_manager` " + "instead", + category=DeprecationWarning, + stacklevel=2 +) + +__all__ = [ + 'LogManager', + 'MAX_LOG_BATCH_PAYLOAD_SIZE' +] From 60cb96b48bea8fd80b1ec8b64ca1ed2548766ec5 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Thu, 15 Sep 2022 19:10:46 +0300 Subject: [PATCH 17/18] Revert "Bump major version due to API update" This reverts commit 7e114bb954c1131ec9dcdfcbdeeeadcad45b32bf. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b01453e5..c00a6429 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages -__version__ = '5.3.0' +__version__ = '5.2.4' with open('requirements.txt') as f: requirements = f.read().splitlines() From b18692c9ec1528b49f3a367f09edd72c34223fb0 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Thu, 15 Sep 2022 19:20:00 +0300 Subject: [PATCH 18/18] Pydocstyle fix --- reportportal_client/core/log_manager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reportportal_client/core/log_manager.py b/reportportal_client/core/log_manager.py index aa1fe8dd..cbc82fa4 100644 --- a/reportportal_client/core/log_manager.py +++ b/reportportal_client/core/log_manager.py @@ -11,7 +11,8 @@ # See the License for the specific language governing permissions and # limitations under the License -""" +"""Deprecated module stub to avoid execution crashes. + .. deprecated:: 5.2.4 Use `logs.log_manager` instead. """