Skip to content
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions pytest_reportportal/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
20 changes: 16 additions & 4 deletions pytest_reportportal/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions pytest_reportportal/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -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
6 changes: 2 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from setuptools import setup

__version__ = "5.6.1"
__version__ = "5.6.2"


def read_file(fname):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
8 changes: 6 additions & 2 deletions tests/unit/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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

Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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
Expand Down
Loading