diff --git a/.flake8 b/.flake8 index 791f075d..9141e879 100644 --- a/.flake8 +++ b/.flake8 @@ -1,2 +1,3 @@ [flake8] +exclude = .git,venv,env max-line-length = 119 diff --git a/CHANGELOG.md b/CHANGELOG.md index 572ba318..d8ca9d2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ # Changelog ## [Unreleased] +### Changed +- Unified ReportPortal product naming, by @HardNorth +- `RPClient` internal item stack implementation changed to `LifoQueue` to maintain concurrency better, by @HardNorth +### Removed +- Unused `delayed_assert` dependency, by @HardNorth + +## [5.4.0] ### Added - `launch_uuid_print` and `print_output` arguments in `RPClient` class constructor, by @HardNorth ### Removed diff --git a/README.md b/README.md index 196d2c51..70b5662a 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ from reportportal_client.helpers import timestamp endpoint = "http://docker.local:8080" project = "default" -# You can get UUID from user profile page in the Report Portal. +# You can get UUID from user profile page in the ReportPortal. api_key = "1adf271d-505f-44a8-ad71-0afbdf8c83bd" launch_name = "Test launch" launch_doc = "Testing logging with attachment." diff --git a/reportportal_client/_local/__init__.py b/reportportal_client/_local/__init__.py index 82cc8238..9cef441e 100644 --- a/reportportal_client/_local/__init__.py +++ b/reportportal_client/_local/__init__.py @@ -1,4 +1,4 @@ -"""Report Portal client context storing and retrieving module.""" +"""ReportPortal client context storing and retrieving module.""" # Copyright (c) 2022 EPAM Systems # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,17 +19,17 @@ def current(): - """Return current Report Portal client.""" + """Return current ReportPortal client.""" if hasattr(__INSTANCES, 'current'): return __INSTANCES.current def set_current(client): - """Save Report Portal client as current. + """Save ReportPortal client as current. - The method is not intended to use used by users. Report Portal client calls + The method is not intended to use used by users. ReportPortal client calls it itself when new client is created. - :param client: Report Portal client + :param client: ReportPortal client """ __INSTANCES.current = client diff --git a/reportportal_client/client.py b/reportportal_client/client.py index 534da666..9bc757d1 100644 --- a/reportportal_client/client.py +++ b/reportportal_client/client.py @@ -1,4 +1,4 @@ -"""This module contains Report Portal Client class.""" +"""This module contains ReportPortal Client class.""" # Copyright (c) 2023 EPAM Systems # Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,6 +17,7 @@ import sys import warnings from os import getenv +from queue import LifoQueue from typing import Union, Tuple, List, Dict, Any, Optional, TextIO import requests @@ -41,11 +42,18 @@ logger.addHandler(logging.NullHandler()) +class _LifoQueue(LifoQueue): + def last(self): + with self.mutex: + if self._qsize(): + return self.queue[-1] + + class RPClient: - """Report portal client. + """ReportPortal client. - The class is supposed to use by Report Portal agents: both custom and - official to make calls to Report Portal. It handles HTTP request and + The class is supposed to use by ReportPortal agents: both custom and + official to make calls to RReportPortal. It handles HTTP request and response bodies generation and serialization, connection retries and log batching. NOTICE: the class is not thread-safe, use new class instance for every new @@ -74,7 +82,7 @@ class RPClient: launch_uuid_print: Optional[bool] = ... print_output: Optional[TextIO] = ... _skip_analytics: str = ... - _item_stack: List[str] = ... + _item_stack: _LifoQueue = ... def __init__( self, @@ -96,7 +104,7 @@ def __init__( ) -> None: """Initialize required attributes. - :param endpoint: Endpoint of the report portal service + :param endpoint: Endpoint of the ReportPortal service :param project: Project name to report to :param api_key: Authorization API key :param log_batch_size: Option to set the maximum number of @@ -133,7 +141,7 @@ def __init__( self.max_pool_size = max_pool_size self.http_timeout = http_timeout self.step_reporter = StepReporter(self) - self._item_stack = [] + self._item_stack = _LifoQueue() self.mode = mode self._skip_analytics = getenv('AGENT_NO_ANALYTICS') self.launch_uuid_print = launch_uuid_print @@ -262,7 +270,7 @@ def finish_test_item(self, verify_ssl=self.verify_ssl).make() if not response: return - self._item_stack.pop() if len(self._item_stack) > 0 else None + self._remove_current_item() logger.debug('finish_test_item - ID: %s', item_id) logger.debug('response message: %s', response.message) return response.message @@ -343,7 +351,7 @@ def get_project_settings(self) -> Optional[Dict]: def log(self, time: str, message: str, level: Optional[Union[int, str]] = None, attachment: Optional[Dict] = None, item_id: Optional[str] = None) -> None: - """Send log message to the Report Portal. + """Send log message to the ReportPortal. :param time: Time in UTC :param message: Log message text @@ -422,7 +430,7 @@ def start_launch(self, self._log_manager.launch_id = self.launch_id = response.id logger.debug('start_launch - ID: %s', self.launch_id) if self.launch_uuid_print and self.print_output: - print(f'Report Portal Launch UUID: {self.launch_id}', file=self.print_output) + print(f'ReportPortal Launch UUID: {self.launch_id}', file=self.print_output) return self.launch_id def start_test_item(self, @@ -488,7 +496,7 @@ def start_test_item(self, item_id = response.id if item_id is not NOT_FOUND: logger.debug('start_test_item - ID: %s', item_id) - self._item_stack.append(item_id) + self._add_current_item(item_id) else: logger.warning('start_test_item - invalid response: %s', str(response.json)) @@ -500,7 +508,7 @@ def terminate(self, *_: Any, **__: Any) -> None: def update_test_item(self, item_uuid: str, attributes: Optional[Union[List, Dict]] = None, description: Optional[str] = None) -> Optional[str]: - """Update existing test item at the Report Portal. + """Update existing test item at the ReportPortal. :param str item_uuid: Test item UUID returned on the item start :param str description: Test item description @@ -520,9 +528,17 @@ def update_test_item(self, item_uuid: str, attributes: Optional[Union[List, Dict logger.debug('update_test_item - Item: %s', item_id) return response.message + def _add_current_item(self, item: str) -> None: + """Add the last item from the self._items queue.""" + self._item_stack.put(item) + + def _remove_current_item(self) -> str: + """Remove the last item from the self._items queue.""" + return self._item_stack.get() + def current_item(self) -> Optional[str]: """Retrieve the last item reported by the client.""" - return self._item_stack[-1] if len(self._item_stack) > 0 else None + return self._item_stack.last() def clone(self) -> 'RPClient': """Clone the client object, set current Item ID as cloned item ID. @@ -546,7 +562,7 @@ def clone(self) -> 'RPClient': ) current_item = self.current_item() if current_item: - cloned._item_stack.append(current_item) + cloned._add_current_item(current_item) return cloned def __getstate__(self) -> Dict[str, Any]: diff --git a/reportportal_client/core/rp_requests.py b/reportportal_client/core/rp_requests.py index 9f2b6b18..7956e755 100644 --- a/reportportal_client/core/rp_requests.py +++ b/reportportal_client/core/rp_requests.py @@ -68,7 +68,7 @@ def __init__(self, session_method, url, data=None, json=None, self.name = name def make(self): - """Make HTTP request to the Report Portal API.""" + """Make HTTP request to the ReportPortal API.""" try: return RPResponse(self.session_method( self.url, data=self.data, json=self.json, @@ -78,7 +78,7 @@ def make(self): # https://github.com/reportportal/client-Python/issues/39 except (KeyError, IOError, ValueError, TypeError) as exc: logger.warning( - "Report Portal %s request failed", + "ReportPortal %s request failed", self.name, exc_info=exc ) diff --git a/reportportal_client/core/test_manager.py b/reportportal_client/core/test_manager.py index 9fdc2ddc..0f8e2d19 100644 --- a/reportportal_client/core/test_manager.py +++ b/reportportal_client/core/test_manager.py @@ -48,7 +48,7 @@ def __init__(self, :param session: Session object :param endpoint: Endpoint url - :param launch_id: Report portal launch UUID + :param launch_id: ReportPortal launch UUID :param project_name: RP project name """ self.session = session @@ -124,7 +124,7 @@ def start_test_item(self, def update_test_item(self, api_version, item_uuid, attributes=None, description=None, **kwargs): - """Update existing test item at the Report Portal. + """Update existing test item at the ReportPortal. :param api_version: RP API version :param str item_uuid: test item UUID returned on the item start @@ -201,7 +201,7 @@ def get_test_item(self, item_uuid): :param item_uuid: test item uuid :return: test item object if found else None """ - # Todo: add 'force' parameter to get item from report portal server + # Todo: add 'force' parameter to get item from ReportPortal server # instead of cache and update cache data according to this request return self._find_item(item_uuid, self.__storage) diff --git a/reportportal_client/core/worker.py b/reportportal_client/core/worker.py index 92acdf04..64127c55 100644 --- a/reportportal_client/core/worker.py +++ b/reportportal_client/core/worker.py @@ -54,7 +54,7 @@ def __lt__(self, other): class APIWorker(object): - """Worker that makes HTTP requests to the Report Portal.""" + """Worker that makes HTTP requests to the ReportPortal.""" def __init__(self, task_queue): """Initialize instance attributes.""" diff --git a/reportportal_client/helpers.py b/reportportal_client/helpers.py index 51a0f8b8..b52e5078 100644 --- a/reportportal_client/helpers.py +++ b/reportportal_client/helpers.py @@ -47,7 +47,7 @@ def dict_to_payload(dictionary): """Convert incoming dictionary to the list of dictionaries. This function transforms the given dictionary of tags/attributes into - the format required by the Report Portal API. Also, we add the system + the format required by the ReportPortal API. Also, we add the system key to every tag/attribute that indicates that the key should be hidden from the user in UI. :param dictionary: Dictionary containing tags/attributes diff --git a/reportportal_client/items/rp_base_item.py b/reportportal_client/items/rp_base_item.py index 6979e2a4..e5c63da5 100644 --- a/reportportal_client/items/rp_base_item.py +++ b/reportportal_client/items/rp_base_item.py @@ -23,7 +23,7 @@ def __init__(self, rp_url, session, project_name, launch_uuid, generated_id): """Initialize instance attributes. - :param rp_url: report portal url + :param rp_url: ReportPortal url :param session: Session object :param project_name: RP project name :param launch_uuid: Parent launch UUID diff --git a/reportportal_client/items/rp_log_items/rp_log_item.py b/reportportal_client/items/rp_log_items/rp_log_item.py index fedd473c..409eab82 100644 --- a/reportportal_client/items/rp_log_items/rp_log_item.py +++ b/reportportal_client/items/rp_log_items/rp_log_item.py @@ -29,7 +29,7 @@ def __init__(self, rp_url, session, project_name, launch_uuid, generated_id): """Initialize instance attributes. - :param rp_url: report portal URL + :param rp_url: ReportPortal URL :param session: Session object :param project_name: RP project name :param launch_uuid: Parent launch UUID diff --git a/reportportal_client/items/rp_test_items/rp_base_test_item.py b/reportportal_client/items/rp_test_items/rp_base_test_item.py index 5b4d318a..d7b18df6 100644 --- a/reportportal_client/items/rp_test_items/rp_base_test_item.py +++ b/reportportal_client/items/rp_test_items/rp_base_test_item.py @@ -27,7 +27,7 @@ def __init__(self, rp_url, session, project_name, item_name, item_type, launch_uuid, generated_id, **kwargs): """Initialize instance attributes. - :param rp_url: report portal url + :param rp_url: ReportPortal url :param session: Session object :param project_name: RP project name :param item_name: RP item name diff --git a/reportportal_client/items/rp_test_items/rp_child_test_item.py b/reportportal_client/items/rp_test_items/rp_child_test_item.py index 3a09c01d..5a5495d6 100644 --- a/reportportal_client/items/rp_test_items/rp_child_test_item.py +++ b/reportportal_client/items/rp_test_items/rp_child_test_item.py @@ -31,7 +31,7 @@ def __init__(self, rp_url, session, project_name, parent_item, **kwargs): """Initialize instance attributes. - :param rp_url: report portal url + :param rp_url: ReportPortal url :param session: Session object :param project_name: RP project name :param item_name: RP item name diff --git a/reportportal_client/items/rp_test_items/rp_root_test_item.py b/reportportal_client/items/rp_test_items/rp_root_test_item.py index 40d887f7..5b11b72e 100644 --- a/reportportal_client/items/rp_test_items/rp_root_test_item.py +++ b/reportportal_client/items/rp_test_items/rp_root_test_item.py @@ -29,7 +29,7 @@ def __init__(self, rp_url, session, project_name, item_name, item_type, launch_uuid, generated_id, **kwargs): """Initialize instance attributes. - :param rp_url: report portal url + :param rp_url: ReportPortal url :param session: Session object :param project_name: RP project name :param item_name: RP item name diff --git a/reportportal_client/logs/__init__.py b/reportportal_client/logs/__init__.py index 269018ed..0d71eef2 100644 --- a/reportportal_client/logs/__init__.py +++ b/reportportal_client/logs/__init__.py @@ -10,7 +10,7 @@ # 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 -"""Report portal logging handling module.""" +"""ReportPortal logging handling module.""" import logging import sys @@ -111,12 +111,11 @@ def __init__(self, level=logging.NOTSET, filter_client_logs=False, :param level: level of logging :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, optional - parameter - :param ignored_record_names: a tuple of record names which will be - filtered out by the handler (with startswith method) + ReportPortal client + :param endpoint: ReportPortal endpoint URL, used to filter out urllib3 logs, mutes + ReportPortal 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) """ super(RPLogHandler, self).__init__(level) self.filter_client_logs = filter_client_logs diff --git a/reportportal_client/logs/log_manager.py b/reportportal_client/logs/log_manager.py index c93642fe..3533bce5 100644 --- a/reportportal_client/logs/log_manager.py +++ b/reportportal_client/logs/log_manager.py @@ -42,7 +42,7 @@ def __init__(self, rp_url, session, api_version, launch_id, project_name, max_payload_size=MAX_LOG_BATCH_PAYLOAD_SIZE): """Initialize instance attributes. - :param rp_url: Report portal URL + :param rp_url: ReportPortal URL :param session: HTTP Session object :param api_version: RP API version :param launch_id: Parent launch UUID diff --git a/reportportal_client/steps/__init__.py b/reportportal_client/steps/__init__.py index 23fc9669..6b36e22a 100644 --- a/reportportal_client/steps/__init__.py +++ b/reportportal_client/steps/__init__.py @@ -10,9 +10,9 @@ # 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 -"""Report portal Nested Step handling module. +"""ReportPortal Nested Step handling module. -The module for handling and reporting Report Portal Nested Steps inside python +The module for handling and reporting ReportPortal Nested Steps inside python test frameworks. Import 'step' function to use it as decorator or together with 'with' keyword to divide your tests on smaller steps. @@ -59,7 +59,7 @@ class StepReporter: def __init__(self, rp_client): """Initialize required attributes. - :param rp_client: Report Portal client which will be used to report + :param rp_client: ReportPortal client which will be used to report steps """ self.client = rp_client @@ -69,7 +69,7 @@ def start_nested_step(self, start_time, parameters=None, **kwargs): - """Start Nested Step on Report Portal. + """Start Nested Step on ReportPortal. :param name: Nested Step name :param start_time: Nested Step start time @@ -88,7 +88,7 @@ def finish_nested_step(self, end_time, status=None, **kwargs): - """Finish a Nested Step on Report Portal. + """Finish a Nested Step on ReportPortal. :param item_id: Nested Step item ID :param end_time: Nested Step finish time @@ -107,7 +107,7 @@ def __init__(self, name, params, status, rp_client): :param params: Nested Step parameters :param status: Nested Step status which will be reported on successful step finish - :param rp_client: Report Portal client which will be used to report + :param rp_client: ReportPortal client which will be used to report the step """ self.name = name @@ -170,16 +170,16 @@ def wrapper(*args, **kwargs): def step(name_source, params=None, status='PASSED', rp_client=None): """Nested step report function. - Create a Nested Step inside a test method on Report Portal. + Create a Nested Step inside a test method on ReportPortal. :param name_source: a function or string which will be used as step's name :param params: nested step parameters which will be reported as the first step entry. If 'name_source' is a function reference and this parameter is not specified, they will be taken from the function. :param status: the status which will be reported after the step - passed. Can be any of legal Report Portal statuses. + passed. Can be any of legal ReportPortal statuses. E.G.: PASSED, WARN, INFO, etc. Default value is PASSED - :param rp_client: overrides Report Portal client which will be used in + :param rp_client: overrides ReportPortal client which will be used in step reporting :return: a step context object """ diff --git a/requirements-dev.txt b/requirements-dev.txt index 78b1a862..9955decc 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,2 @@ -delayed-assert pytest pytest-cov diff --git a/requirements.txt b/requirements.txt index c2c76268..549e8374 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ aenum -delayed_assert requests>=2.27.1 six>=1.16.0 diff --git a/setup.py b/setup.py index ef554306..890d811e 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup, find_packages -__version__ = '5.4.0' +__version__ = '5.4.1' TYPE_STUBS = ['*.pyi'] @@ -27,10 +27,10 @@ def read_file(fname): 'reportportal_client.steps': TYPE_STUBS }, version=__version__, - description='Python client for Report Portal v5.', + description='Python client for ReportPortal v5.', long_description=read_file('README.md'), long_description_content_type='text/markdown', - author='Report Portal Team', + author='ReportPortal Team', author_email='support@reportportal.io', url='https://github.com/reportportal/client-Python', download_url=('https://github.com/reportportal/client-Python/' diff --git a/tests/logs/test_rp_logger.py b/tests/logs/test_rp_logger.py index a893d820..9475b3ed 100644 --- a/tests/logs/test_rp_logger.py +++ b/tests/logs/test_rp_logger.py @@ -75,10 +75,11 @@ def test_log_level_filter(handler_level, log_level, expected_calls): @mock.patch('reportportal_client.logs.logging.Logger.handle') def test_stacklevel_record_make(logger_handler): logger = RPLogger('test_logger') - logger.error('test_log', exc_info=RuntimeError('test'), - stack_info=inspect.stack(), stacklevel=2) - record = verify_record(logger_handler) if sys.version_info < (3, 11): - assert record.stack_info.endswith('return func(*newargs, **newkeywargs)') + logger.error('test_log', exc_info=RuntimeError('test'), + stack_info=inspect.stack(), stacklevel=1) else: - assert record.stack_info.endswith("logger.error('test_log', exc_info=RuntimeError('test'),") + logger.error('test_log', exc_info=RuntimeError('test'), + stack_info=inspect.stack(), stacklevel=2) + record = verify_record(logger_handler) + assert record.stack_info.endswith("logger.error('test_log', exc_info=RuntimeError('test'),") diff --git a/tests/steps/test_steps.py b/tests/steps/test_steps.py index 32fb2cf4..2a6615ad 100644 --- a/tests/steps/test_steps.py +++ b/tests/steps/test_steps.py @@ -31,7 +31,7 @@ def test_nested_steps_are_skipped_without_parent(rp_client): def test_nested_steps_reported_with_parent(rp_client): - rp_client._item_stack.append(PARENT_STEP_ID) + rp_client._add_current_item(PARENT_STEP_ID) with step(NESTED_STEP_NAME): pass @@ -41,7 +41,7 @@ def test_nested_steps_reported_with_parent(rp_client): def test_nested_steps_are_skipped_without_client(rp_client): - rp_client._item_stack.append(PARENT_STEP_ID) + rp_client._add_current_item(PARENT_STEP_ID) set_current(None) with step(NESTED_STEP_NAME): pass @@ -51,7 +51,7 @@ def test_nested_steps_are_skipped_without_client(rp_client): def test_nested_step_name(rp_client): - rp_client._item_stack.append(PARENT_STEP_ID) + rp_client._add_current_item(PARENT_STEP_ID) with step(NESTED_STEP_NAME): pass @@ -61,7 +61,7 @@ def test_nested_step_name(rp_client): def test_nested_step_times(rp_client): - rp_client._item_stack.append(PARENT_STEP_ID) + rp_client._add_current_item(PARENT_STEP_ID) with step(NESTED_STEP_NAME): pass @@ -76,7 +76,7 @@ def nested_step(): def test_nested_step_decorator(rp_client): - rp_client._item_stack.append(PARENT_STEP_ID) + rp_client._add_current_item(PARENT_STEP_ID) nested_step() assert rp_client.session.post.call_count == 1 @@ -85,7 +85,7 @@ def test_nested_step_decorator(rp_client): def test_nested_step_failed(rp_client): - rp_client._item_stack.append(PARENT_STEP_ID) + rp_client._add_current_item(PARENT_STEP_ID) try: with step(NESTED_STEP_NAME): raise AssertionError @@ -97,7 +97,7 @@ def test_nested_step_failed(rp_client): def test_nested_step_custom_status(rp_client): - rp_client._item_stack.append(PARENT_STEP_ID) + rp_client._add_current_item(PARENT_STEP_ID) with step(NESTED_STEP_NAME, status='INFO'): pass assert rp_client.session.post.call_count == 1 @@ -106,7 +106,7 @@ def test_nested_step_custom_status(rp_client): def test_nested_step_custom_status_failed(rp_client): - rp_client._item_stack.append(PARENT_STEP_ID) + rp_client._add_current_item(PARENT_STEP_ID) try: with step(NESTED_STEP_NAME, status='INFO'): raise AssertionError @@ -134,7 +134,7 @@ def nested_step_params(param1, param2, param3=None): def test_verify_parameters_logging_default_value(rp_client): rp_client.session.post.side_effect = item_id_gen - rp_client._item_stack.append(PARENT_STEP_ID) + rp_client._add_current_item(PARENT_STEP_ID) nested_step_params(1, 'two') assert len(rp_client._log_manager._batch) == 1 assert rp_client._log_manager._batch[0].message \ @@ -143,7 +143,7 @@ def test_verify_parameters_logging_default_value(rp_client): def test_verify_parameters_logging_no_default_value(rp_client): rp_client.session.post.side_effect = item_id_gen - rp_client._item_stack.append(PARENT_STEP_ID) + rp_client._add_current_item(PARENT_STEP_ID) nested_step_params(1, 'two', 'three') assert len(rp_client._log_manager._batch) == 1 assert rp_client._log_manager._batch[0].message \ @@ -152,7 +152,7 @@ def test_verify_parameters_logging_no_default_value(rp_client): def test_verify_parameters_logging_named_value(rp_client): rp_client.session.post.side_effect = item_id_gen - rp_client._item_stack.append(PARENT_STEP_ID) + rp_client._add_current_item(PARENT_STEP_ID) nested_step_params(1, 'two', param3='three') assert len(rp_client._log_manager._batch) == 1 assert rp_client._log_manager._batch[0].message \ @@ -161,7 +161,7 @@ def test_verify_parameters_logging_named_value(rp_client): def test_verify_parameters_inline_logging(rp_client): rp_client.session.post.side_effect = item_id_gen - rp_client._item_stack.append(PARENT_STEP_ID) + rp_client._add_current_item(PARENT_STEP_ID) with step(NESTED_STEP_NAME, params={'param1': 1, 'param2': 'two'}): pass assert len(rp_client._log_manager._batch) == 1 @@ -175,7 +175,7 @@ def parent_nested_step(): def test_two_level_nested_step_decorator(rp_client): - rp_client._item_stack.append(PARENT_STEP_ID) + rp_client._add_current_item(PARENT_STEP_ID) rp_client.session.post.side_effect = item_id_gen parent_nested_step() @@ -202,7 +202,7 @@ def test_two_level_nested_step_decorator(rp_client): def test_verify_manual_client_bypass_step(rp_client): set_current(None) - rp_client._item_stack.append(PARENT_STEP_ID) + rp_client._add_current_item(PARENT_STEP_ID) with step(NESTED_STEP_NAME, rp_client=rp_client): pass assert rp_client.session.post.call_count == 1 diff --git a/tests/test_client.py b/tests/test_client.py index b4cc4020..0e1f34ad 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -150,8 +150,8 @@ def test_clone(): 'http_timeout': (30, 30), 'log_batch_payload_size': 1000000, 'mode': 'DEBUG'} client = RPClient(*args, **kwargs) - client._item_stack.append('test-321') - client._item_stack.append('test-322') + client._add_current_item('test-321') + client._add_current_item('test-322') cloned = client.clone() assert cloned is not None and client is not cloned assert cloned.endpoint == args[0] and cloned.project == args[1] @@ -165,7 +165,7 @@ def test_clone(): 'launch_id'] and cloned.http_timeout == kwargs[ 'http_timeout'] and cloned.log_batch_payload_size == kwargs[ 'log_batch_payload_size'] and cloned.mode == kwargs['mode'] - assert len(cloned._item_stack) == 1 \ + assert cloned._item_stack.qsize() == 1 \ and client.current_item() == cloned.current_item() @@ -206,7 +206,7 @@ def test_launch_uuid_print(): client.session = mock.Mock() client._skip_analytics = True client.start_launch('Test Launch', timestamp()) - assert 'Report Portal Launch UUID: ' in str_io.getvalue() + assert 'ReportPortal Launch UUID: ' in str_io.getvalue() def test_no_launch_uuid_print(): @@ -216,7 +216,7 @@ def test_no_launch_uuid_print(): client.session = mock.Mock() client._skip_analytics = True client.start_launch('Test Launch', timestamp()) - assert 'Report Portal Launch UUID: ' not in str_io.getvalue() + assert 'ReportPortal Launch UUID: ' not in str_io.getvalue() @mock.patch('reportportal_client.client.sys.stdout', new_callable=StringIO) @@ -227,7 +227,7 @@ def test_launch_uuid_print_default_io(mock_stdout): client._skip_analytics = True client.start_launch('Test Launch', timestamp()) - assert 'Report Portal Launch UUID: ' in mock_stdout.getvalue() + assert 'ReportPortal Launch UUID: ' in mock_stdout.getvalue() @mock.patch('reportportal_client.client.sys.stdout', new_callable=StringIO) @@ -238,4 +238,4 @@ def test_launch_uuid_print_default_print(mock_stdout): client._skip_analytics = True client.start_launch('Test Launch', timestamp()) - assert 'Report Portal Launch UUID: ' not in mock_stdout.getvalue() + assert 'ReportPortal Launch UUID: ' not in mock_stdout.getvalue()