diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b8c3d4..8beefd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ ## [Unreleased] ### Added +- `rp_launch_uuid` configuration parameter, by @HardNorth +- `rp_launch_attributes` cmd argument, by @fahadnaeemkhan +### Changed +- Client version updated on [5.7.1](https://github.com/reportportal/client-Python/releases/tag/5.7.1), by @HardNorth + +## [5.6.1] +### Added - Config variables override by environment variables logic, by @HardNorth ### Fixed - Code reference generation in `xdist`, by @Sgitario diff --git a/pytest_reportportal/config.py b/pytest_reportportal/config.py index 0352fa7..0d6a702 100644 --- a/pytest_reportportal/config.py +++ b/pytest_reportportal/config.py @@ -44,7 +44,7 @@ class AgentConfig: rp_bts_project: str rp_bts_url: str rp_launch: str - rp_launch_id: Optional[str] + rp_launch_uuid: Optional[str] rp_launch_attributes: Optional[list[str]] rp_tests_attributes: Optional[list[str]] rp_launch_description: str @@ -105,7 +105,16 @@ def __init__(self, pytest_config: Config) -> None: self.rp_bts_project = self.find_option(pytest_config, "rp_bts_project") self.rp_bts_url = self.find_option(pytest_config, "rp_bts_url") self.rp_launch = self.find_option(pytest_config, "rp_launch") - self.rp_launch_id = self.find_option(pytest_config, "rp_launch_id") + self.rp_launch_uuid = self.find_option(pytest_config, "rp_launch_id") + if self.rp_launch_uuid: + warnings.warn( + "Parameter `rp_launch_id` is deprecated since 5.6.2 and will be subject for removing" + "in the next major version. Use `rp_launch_uuid` argument instead.", + DeprecationWarning, + 2, + ) + self.rp_launch_uuid = self.find_option(pytest_config, "rp_launch_uuid", self.rp_launch_uuid) + self.rp_launch_attributes = self.find_option(pytest_config, "rp_launch_attributes") self.rp_tests_attributes = self.find_option(pytest_config, "rp_tests_attributes") self.rp_launch_description = self.find_option(pytest_config, "rp_launch_description") diff --git a/pytest_reportportal/plugin.py b/pytest_reportportal/plugin.py index 8d8465b..1798b14 100644 --- a/pytest_reportportal/plugin.py +++ b/pytest_reportportal/plugin.py @@ -86,7 +86,7 @@ def wait_launch(rp_client: RP) -> bool: :param rp_client: Instance of the ReportPortalService class """ timeout = time.time() + LAUNCH_WAIT_TIMEOUT - while not rp_client.launch_id: + while not rp_client.launch_uuid: if time.time() > timeout: return False time.sleep(1) @@ -531,7 +531,11 @@ def add_shared_option(name, help_str, default=None, action="store"): ) add_shared_option( name="rp_launch_id", - help_str="Use already existing launch-id. The plugin won't control " "the Launch status", + help_str="DEPRECATED: Use already existing launch-id. The plugin won't control the Launch status", + ) + add_shared_option( + name="rp_launch_uuid", + help_str="Use already existing launch UUID. The plugin won't control the Launch status", ) add_shared_option( name="rp_launch_description", @@ -590,8 +594,16 @@ def add_shared_option(name, help_str, default=None, action="store"): parser.addini("rp_oauth_client_secret", type="args", help="OAuth 2.0 client secret") parser.addini("rp_oauth_scope", type="args", help="OAuth 2.0 access token scope") - parser.addini("rp_launch_attributes", type="args", help="Launch attributes, i.e Performance Regression") - parser.addini("rp_tests_attributes", type="args", help="Attributes for all tests items, e.g. Smoke") + rp_launch_attributes_help_str = "Launch attributes, i.e Performance Regression." + parser.addini("rp_launch_attributes", type="args", help=rp_launch_attributes_help_str) + group.addoption( + "--rp-launch-attributes", dest="rp_launch_attributes", help=rp_launch_attributes_help_str, nargs="+" + ) + + rp_test_attributes_help_str = "Attributes for all tests items, e.g. Smoke." + parser.addini("rp_tests_attributes", type="args", help=rp_test_attributes_help_str) + group.addoption("--rp-tests-attributes", dest="rp_tests_attributes", help=rp_test_attributes_help_str, nargs="+") + parser.addini("rp_log_batch_size", default="20", help="Size of batch log requests in async mode") parser.addini( "rp_log_batch_payload_limit", diff --git a/pytest_reportportal/service.py b/pytest_reportportal/service.py index 235ebc7..c0dff67 100644 --- a/pytest_reportportal/service.py +++ b/pytest_reportportal/service.py @@ -74,7 +74,7 @@ except ImportError: Rule = type("dummy", (), {}) # Old pytest-bdd versions do not have Rule -from reportportal_client import RP, create_client +from reportportal_client import RP, ClientType, create_client from reportportal_client.helpers import dict_to_payload, gen_attributes, get_launch_sys_attrs, get_package_version LOGGER = logging.getLogger(__name__) @@ -1417,10 +1417,10 @@ def start(self) -> None: self._config.rp_api_key, ) launch_id = self._launch_id - if self._config.rp_launch_id: - launch_id = self._config.rp_launch_id + if self._config.rp_launch_uuid: + launch_id = self._config.rp_launch_uuid self.rp = create_client( - client_type=self._config.rp_client_type, + client_type=self._config.rp_client_type or ClientType.SYNC, endpoint=self._config.rp_endpoint, project=self._config.rp_project, api_key=self._config.rp_api_key, diff --git a/requirements-dev.txt b/requirements-dev.txt index a6ccdfb..4f1e860 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,6 +1,8 @@ +dill>=0.3.6 +pytest>=4.6.10 delayed-assert pytest-cov pytest-parallel black isort -mypy +mypy==1.19.1 diff --git a/requirements.txt b/requirements.txt index 21bc458..ca2b79b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,2 @@ -dill>=0.3.6 -pytest>=4.6.10 -reportportal-client~=5.7.0 -aenum>=3.1.0 +reportportal-client==5.7.1 +aenum==3.1.17 diff --git a/setup.py b/setup.py index 58ebab9..6f72db0 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ from setuptools import setup -__version__ = "5.6.1" +__version__ = "5.6.2" def read_file(fname): diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py index d8bf04c..c1c932a 100644 --- a/tests/unit/test_config.py +++ b/tests/unit/test_config.py @@ -43,7 +43,7 @@ def test_verify_ssl_true(mocked_config, verify_ssl, expected_result): ("RP_PROJECT", "env_project", "rp_project", "env_project"), ("RP_LAUNCH", "env_launch", "rp_launch", "env_launch"), ("RP_API_KEY", "env_api_key", "rp_api_key", "env_api_key"), - ("RP_LAUNCH_ID", "env_launch_id", "rp_launch_id", "env_launch_id"), + ("RP_LAUNCH_UUID", "env_launch_id", "rp_launch_uuid", "env_launch_id"), ("RP_MODE", "DEBUG", "rp_mode", "DEBUG"), ("RP_PARENT_ITEM_ID", "env_parent_id", "rp_parent_item_id", "env_parent_id"), ("RP_RERUN_OF", "env_rerun_of", "rp_rerun_of", "env_rerun_of"), diff --git a/tests/unit/test_plugin.py b/tests/unit/test_plugin.py index 9912f73..2b0c038 100644 --- a/tests/unit/test_plugin.py +++ b/tests/unit/test_plugin.py @@ -146,7 +146,7 @@ def test_wait_launch(time_mock): """Test wait_launch() function for the correct behavior.""" time_mock.time.side_effect = [0, 1, 2] rp_client = mock.Mock() - rp_client.launch_id = None + rp_client.launch_uuid = None assert not wait_launch(rp_client) @@ -224,7 +224,7 @@ def test_pytest_sessionfinish(mocked_session): :param mocked_session: pytest fixture """ mocked_session.config.py_test_service = mock.Mock() - mocked_session.config._reporter_config.rp_launch_id = None + mocked_session.config._reporter_config.rp_launch_uuid = None pytest_sessionfinish(mocked_session) assert mocked_session.config.py_test_service.finish_launch.called @@ -235,6 +235,7 @@ def test_pytest_addoption_adds_correct_ini_file_arguments(): expected_argument_names = ( "rp_launch", "rp_launch_id", + "rp_launch_uuid", "rp_launch_description", "rp_project", "rp_log_level", @@ -295,6 +296,7 @@ def test_pytest_addoption_adds_correct_command_line_arguments(): "--reportportal", "--rp-launch", "--rp-launch-id", + "--rp-launch-uuid", "--rp-launch-description", "--rp-project", "--rp-log-level", @@ -308,6 +310,8 @@ def test_pytest_addoption_adds_correct_command_line_arguments(): "--rp-thread-logging", "--rp-launch-uuid-print", "--rp-launch-uuid-print-output", + "--rp-launch-attributes", + "--rp-tests-attributes", ) mock_parser = mock.MagicMock(spec=Parser) mock_reporting_group = mock_parser.getgroup.return_value