def test_require_attribute_value(unknown_node: yatiml.UnknownNode) -> None: unknown_node.require_attribute_value('attr1', 42) with pytest.raises(yatiml.RecognitionError): unknown_node.require_attribute_value('attr1', 43) with pytest.raises(yatiml.RecognitionError): unknown_node.require_attribute_value('attr1', 'test') with pytest.raises(yatiml.RecognitionError): unknown_node.require_attribute_value('non_existent_attribute', 'test')
def _yatiml_recognize(cls, node: yatiml.UnknownNode) -> None: node.require_attribute('name', str) node.require_attribute('age', Union[int, str])
def test_require_attribute_value_not(unknown_node: yatiml.UnknownNode) -> None: unknown_node.require_attribute_value_not('attr1', '42') unknown_node.require_attribute_value_not('null_attr', 42) unknown_node.require_attribute_value_not('list1', None) with pytest.raises(yatiml.RecognitionError): unknown_node.require_attribute_value_not('attr1', 42) with pytest.raises(yatiml.RecognitionError): unknown_node.require_attribute_value_not('null_attr', None) with pytest.raises(yatiml.RecognitionError): unknown_node.require_attribute_value_not('non_existent_attribute', 1)
def test_require_sequence(unknown_node: yatiml.UnknownNode, unknown_sequence_node: yatiml.UnknownNode) -> None: unknown_sequence_node.require_sequence() with pytest.raises(yatiml.RecognitionError): unknown_node.require_sequence()
def test_require_attribute(unknown_node: yatiml.UnknownNode) -> None: unknown_node.require_attribute('attr1') with pytest.raises(yatiml.RecognitionError): unknown_node.require_attribute('non_existent_attribute') unknown_node.require_attribute('attr1', int) with pytest.raises(yatiml.RecognitionError): unknown_node.require_attribute('attr1', str) unknown_node.require_attribute('null_attr', None) with pytest.raises(yatiml.RecognitionError): unknown_node.require_attribute('attr1', None) with pytest.raises(yatiml.RecognitionError): unknown_node.require_attribute('null_attr', int)
def yatiml_recognize(cls, node: yatiml.UnknownNode) -> None: node.require_scalar(str)
def test_require_mapping(unknown_node: yatiml.UnknownNode, unknown_scalar_node: yatiml.UnknownNode) -> None: unknown_node.require_mapping() with pytest.raises(yatiml.RecognitionError): unknown_scalar_node.require_mapping()
def yatiml_recognize(cls, node: yatiml.UnknownNode) -> None: node.require_attribute_value('subclass', 'B2')
def _yatiml_recognize(cls, node: yatiml.UnknownNode) -> None: node.require_attribute('model', Model) node.require_attribute('implementations') node.require_attribute('resources')
def _yatiml_recognize(cls, node: yatiml.UnknownNode) -> None: # In the YAML file, a Settings is just a mapping... node.require_mapping()
def _yatiml_recognize(cls, node: yatiml.UnknownNode) -> None: node.require_mapping() node.require_attribute('name') node.require_attribute('components')
def _yatiml_recognize(cls, node: yatiml.UnknownNode) -> None: node.require_mapping() node.require_attribute('ymmsl_version') node.require_attribute_value('ymmsl_version', 'v0.1')