test_model_data_builder
Tests for ModelDataBuilder class
test_model_data_builder_gives_error_when_rule_not_defined()
The ModelDataBuilder should throw an exception when one of the rules is not defined
Source code in tests/data/entities/test_model_data_builder.py
def test_model_data_builder_gives_error_when_rule_not_defined():
"""The ModelDataBuilder should throw an exception
when one of the rules is not defined"""
# Arrange
logger = Mock(ILogger)
# Act
data = ModelDataBuilder(logger)
contents["rules"][0] = {"wrong_rule": "test"}
contents["version"] = "0.0.0"
with pytest.raises(KeyError) as exc_info:
data.parse_yaml_data(contents)
exception_raised = exc_info.value
# Assert
exc = exception_raised.args[0]
assert exc.endswith("No parser for wrong_rule")
test_model_data_builder_parse_dict_to_model_data()
The ModelDataBuilder should parse the provided dictionary to a IModelData object
Source code in tests/data/entities/test_model_data_builder.py
def test_model_data_builder_parse_dict_to_model_data():
"""The ModelDataBuilder should parse the provided dictionary
to a IModelData object"""
# Arrange
logger = Mock(ILogger)
# Act
data = ModelDataBuilder(logger)
contents["version"] = "0.0.0"
parsed_data = data.parse_yaml_data(contents)
# Assert
assert isinstance(parsed_data, IModelData)