def test_finish_failed_step_step_based(mock_timestamp, config): config.step_based = True mock_step = mock.Mock() mock_step.keyword = "keyword" mock_step.name = "name" mock_step.status.name = "failed" mock_step.exception.args = ["Exception message"] mock_step.error_message = "Error massage" mock_timestamp.return_value = 123 mock_rps = mock.create_autospec(ReportPortalService) mock_context = mock.Mock() ba = BehaveAgent(config, mock_rps) ba._step_id = "step_id" ba._scenario_id = "step_id" ba.finish_step(mock_context, mock_step, some_key="some_value") mock_rps.finish_test_item.assert_called_once_with( item_id="step_id", end_time=123, status="FAILED", some_key="some_value" ) mock_rps.log.assert_has_calls( [ mock.call( item_id="step_id", time=123, level="ERROR", message="Step [keyword]: name was finished with exception.\n" "Exception message\nError massage", ) ] )
def test_finish_passed_step_step_based(mock_timestamp, config): config.step_based = True mock_step = mock.Mock() mock_step.status.name = "passed" mock_timestamp.return_value = 123 mock_rps = mock.create_autospec(ReportPortalService) mock_context = mock.Mock() ba = BehaveAgent(config, mock_rps) ba._step_id = "step_id" ba.finish_step(mock_context, mock_step, some_key="some_value") mock_rps.finish_test_item.assert_called_once_with( item_id="step_id", end_time=123, status="PASSED", some_key="some_value" )
def test_start_step_step_based(mock_timestamp, config): config.step_based = True mock_step = mock.Mock() mock_step.keyword = "keyword" mock_step.name = "name" mock_step.text = None mock_step.table = None mock_timestamp.return_value = 123 mock_rps = mock.create_autospec(ReportPortalService) mock_rps.start_test_item.return_value = "step_id" mock_context = mock.Mock() ba = BehaveAgent(config, mock_rps) ba._scenario_id = "scenario_id" ba.start_step(mock_context, mock_step, some_key="some_value") mock_rps.start_test_item.assert_called_once_with( name="[keyword]: name", start_time=123, item_type="STEP", parent_item_id="scenario_id", description="", code_ref=BehaveAgent._code_ref(mock_step), some_key="some_value", ) ba._step_id = "step_id"