예제 #1
0
 def _yatiml_recognize(cls, node: yatiml.UnknownNode) -> None:
     node.require_attribute('name', str)
     node.require_attribute('age', Union[int, str])
예제 #2
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)
예제 #3
0
 def _yatiml_recognize(cls, node: yatiml.UnknownNode) -> None:
     node.require_mapping()
     node.require_attribute('name')
     node.require_attribute('components')
예제 #4
0
 def _yatiml_recognize(cls, node: yatiml.UnknownNode) -> None:
     node.require_attribute('model', Model)
     node.require_attribute('implementations')
     node.require_attribute('resources')
예제 #5
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')