|
1 | 1 | """This modules includes unit tests for the plugin.""" |
2 | 2 |
|
3 | 3 | from six.moves import mock |
| 4 | +import os |
4 | 5 |
|
5 | 6 | from delayed_assert import expect, assert_expectations |
6 | 7 | import pytest |
7 | 8 | from requests.exceptions import RequestException |
8 | 9 |
|
9 | 10 | from pytest_reportportal.listener import RPReportListener |
10 | | -from pytest_reportportal.plugin import pytest_configure |
| 11 | +from pytest_reportportal.plugin import pytest_configure, pytest_sessionstart |
11 | 12 |
|
12 | 13 |
|
13 | 14 | @mock.patch('pytest_reportportal.plugin.requests.get') |
@@ -138,3 +139,18 @@ def iter_markers(name=None): |
138 | 139 | expect(mocked_item.add_marker.call_args[0][0] == "issue:456823", |
139 | 140 | "item.add_marker called with incorrect parameters") |
140 | 141 | assert_expectations() |
| 142 | + |
| 143 | + |
| 144 | +@mock.patch.dict(os.environ, {'RP_UUID': 'foobar'}) |
| 145 | +def test_uuid_env_var_override(mocked_session): |
| 146 | + """ |
| 147 | + Test setting RP_UUID env variable overrides the rp_uuid config value |
| 148 | + :param mocked_session: pytest fixture |
| 149 | + """ |
| 150 | + mocked_session.config.py_test_service = mock.Mock() |
| 151 | + mocked_session.config.option = mock.Mock() |
| 152 | + mocked_session.config.pluginmanager = mock.Mock() |
| 153 | + mocked_session.config.py_test_service.init_service = mock.Mock() |
| 154 | + pytest_sessionstart(mocked_session) |
| 155 | + args, kwargs = mocked_session.config.py_test_service.init_service.call_args |
| 156 | + assert kwargs.get('uuid') == 'foobar' |
0 commit comments