3232 pytest_sessionstart ,
3333 pytest_sessionfinish ,
3434 wait_launch ,
35- MANDATORY_PARAMETER_MISSED_PATTERN
35+ MANDATORY_PARAMETER_MISSED_PATTERN , FAILED_LAUNCH_WAIT
3636)
3737from pytest_reportportal .service import PyTestServiceClass
3838
@@ -235,9 +235,7 @@ def test_wait_launch(time_mock):
235235 time_mock .time .side_effect = [0 , 1 , 2 ]
236236 rp_client = mock .Mock ()
237237 rp_client .launch_id = None
238- with pytest .raises (Exception ) as err :
239- wait_launch (rp_client )
240- assert str (err .value ) == 'Launch has not started.'
238+ assert not wait_launch (rp_client )
241239
242240
243241def test_pytest_collection_finish (mocked_session ):
@@ -251,12 +249,12 @@ def test_pytest_collection_finish(mocked_session):
251249 assert_called_with (mocked_session )
252250
253251
252+ @mock .patch ('pytest_reportportal.plugin.wait_launch' ,
253+ mock .Mock (return_value = True ))
254254@mock .patch ('pytest_reportportal.plugin.is_control' , mock .Mock ())
255- @mock .patch ('pytest_reportportal.plugin.wait_launch' )
256- def test_pytest_sessionstart (mocked_wait , mocked_session ):
255+ def test_pytest_sessionstart (mocked_session ):
257256 """Test session configuration if RP plugin is correctly configured.
258257
259- :param mocked_wait: Mocked wait_launch function
260258 :param mocked_session: pytest fixture
261259 """
262260 mocked_session .config .pluginmanager .hasplugin .return_value = True
@@ -269,10 +267,34 @@ def test_pytest_sessionstart(mocked_wait, mocked_session):
269267 expect (lambda : mocked_session .config .py_test_service .init_service .called )
270268 expect (lambda : mocked_session .config .py_test_service .rp is not None )
271269 expect (lambda : mocked_session .config .py_test_service .start_launch .called )
272- expect (lambda : mocked_wait .called )
273270 assert_expectations ()
274271
275272
273+ @mock .patch ('pytest_reportportal.plugin.log' , wraps = log )
274+ @mock .patch ('pytest_reportportal.plugin.is_control' , mock .Mock ())
275+ @mock .patch ('pytest_reportportal.plugin.wait_launch' ,
276+ mock .Mock (return_value = False ))
277+ def test_pytest_sessionstart_launch_wait_fail (mocked_log , mocked_session ):
278+ """Test session configuration if RP plugin is correctly configured.
279+
280+ :param mocked_session: pytest fixture
281+ """
282+ mocked_session .config .pluginmanager .hasplugin .return_value = True
283+ mocked_session .config ._reporter_config = mock .Mock (
284+ spec = AgentConfig (mocked_session .config ))
285+ mocked_session .config ._reporter_config .rp_launch_attributes = []
286+ mocked_session .config ._reporter_config .rp_launch_id = None
287+ mocked_session .config .py_test_service = mock .Mock ()
288+ pytest_sessionstart (mocked_session )
289+ expect (lambda : mocked_session .config .py_test_service .rp is None )
290+ assert_expectations ()
291+ mocked_log .error .assert_has_calls (
292+ [
293+ mock .call (FAILED_LAUNCH_WAIT )
294+ ]
295+ )
296+
297+
276298@mock .patch ('pytest_reportportal.plugin.is_control' , mock .Mock ())
277299@mock .patch ('pytest_reportportal.plugin.wait_launch' , mock .Mock ())
278300def test_pytest_sessionstart_with_launch_id (mocked_session ):
0 commit comments