Exemple #1
0
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')
Exemple #2
0
 def _yatiml_recognize(cls, node: yatiml.UnknownNode) -> None:
     node.require_attribute('name', str)
     node.require_attribute('age', Union[int, str])
Exemple #3
0
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)
Exemple #4
0
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()
Exemple #5
0
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)
Exemple #6
0
 def yatiml_recognize(cls, node: yatiml.UnknownNode) -> None:
     node.require_scalar(str)
Exemple #7
0
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()
Exemple #8
0
 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')
Exemple #10
0
 def _yatiml_recognize(cls, node: yatiml.UnknownNode) -> None:
     # In the YAML file, a Settings is just a mapping...
     node.require_mapping()
Exemple #11
0
 def _yatiml_recognize(cls, node: yatiml.UnknownNode) -> None:
     node.require_mapping()
     node.require_attribute('name')
     node.require_attribute('components')
Exemple #12
0
 def _yatiml_recognize(cls, node: yatiml.UnknownNode) -> None:
     node.require_mapping()
     node.require_attribute('ymmsl_version')
     node.require_attribute_value('ymmsl_version', 'v0.1')