Exemplo n.º 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')
Exemplo n.º 2
0
 def _yatiml_recognize(cls, node: yatiml.UnknownNode) -> None:
     node.require_attribute('name', str)
     node.require_attribute('age', Union[int, str])
Exemplo n.º 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)
Exemplo n.º 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()
Exemplo n.º 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)
Exemplo n.º 6
0
 def yatiml_recognize(cls, node: yatiml.UnknownNode) -> None:
     node.require_scalar(str)
Exemplo n.º 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()
Exemplo n.º 8
0
 def yatiml_recognize(cls, node: yatiml.UnknownNode) -> None:
     node.require_attribute_value('subclass', 'B2')
Exemplo n.º 9
0
 def _yatiml_recognize(cls, node: yatiml.UnknownNode) -> None:
     node.require_attribute('model', Model)
     node.require_attribute('implementations')
     node.require_attribute('resources')
Exemplo n.º 10
0
 def _yatiml_recognize(cls, node: yatiml.UnknownNode) -> None:
     # In the YAML file, a Settings is just a mapping...
     node.require_mapping()
Exemplo n.º 11
0
 def _yatiml_recognize(cls, node: yatiml.UnknownNode) -> None:
     node.require_mapping()
     node.require_attribute('name')
     node.require_attribute('components')
Exemplo n.º 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')