def test_attributes(config): mock_item = mock.Mock() mock_item.tags = None mock_rps = mock.create_autospec(ReportPortalService) ba = BehaveAgent(config, mock_rps) expect(ba._attributes(mock_item) == [], "Attributes is not empty") mock_item.tags = ["a", "b", "attribute(k1:v1,v2)"] exp = [ { "value": "a" }, { "value": "b" }, { "key": "k1", "value": "v1" }, { "value": "v2" }, ] act = ba._attributes(mock_item) expect( act == exp, "Attributes are incorrect:\nActual: {}\nExpected: {}".format(act, exp), ) assert_expectations()
def verify_start_scenario(mock_scenario, config): mock_rps = mock.create_autospec(ReportPortalService) mock_rps.start_test_item.return_value = "scenario_id" mock_context = mock.Mock() mock_scenario.name = "scenario_name" mock_scenario._row = None mock_scenario.description = ["A", "B"] ba = BehaveAgent(config, mock_rps) ba._feature_id = "feature_id" ba.start_scenario(mock_context, mock_scenario, some_key="some_value") mock_rps.start_test_item.assert_called_once_with( name="scenario_name", start_time=123, item_type="STEP", parent_item_id="feature_id", description=BehaveAgent._item_description(mock_scenario), code_ref=BehaveAgent._code_ref(mock_scenario), parameters=BehaveAgent._get_parameters(mock_scenario), attributes=ba._attributes(mock_scenario), test_case_id=ba._test_case_id(mock_scenario), some_key="some_value", ) assert ( ba._scenario_id == "scenario_id" ), "Invalid scenario_id:\nActual: {}\nExpected: {}\n".format( ba._scenario_id, "scenario_id" )
def verify_start_feature(mock_feature, config): mock_rps = mock.create_autospec(ReportPortalService) mock_rps.start_test_item.return_value = "feature_id" mock_context = mock.Mock() mock_feature.name = "feature_name" mock_feature.description = ["A", "B"] ba = BehaveAgent(config, mock_rps) ba.start_feature(mock_context, mock_feature, some_key="some_value") mock_rps.start_test_item.assert_called_once_with( name="feature_name", start_time=123, item_type="SUITE", description=BehaveAgent._item_description(mock_feature), code_ref=BehaveAgent._code_ref(mock_feature), attributes=ba._attributes(mock_feature), some_key="some_value", ) assert (ba._feature_id == "feature_id" ), "Invalid feature_id:\nActual: {}\nExpected: {}\n".format( ba._feature_id, "feature_id")