Beispiel #1
0
def test_rename_attribute(class_node: yatiml.Node) -> None:
    assert class_node.has_attribute('attr1')
    assert not class_node.has_attribute('attr2')
    attr1_value = class_node.get_attribute('attr1').get_value()
    class_node.rename_attribute('attr1', 'attr2')
    assert not class_node.has_attribute('attr1')
    assert class_node.has_attribute('attr2')
    assert class_node.get_attribute('attr2').get_value() == attr1_value

    # make sure that this does not raise
    class_node.rename_attribute('non_existent_attribute', 'attr3')
Beispiel #2
0
 def _yatiml_sweeten(cls, node: yatiml.Node) -> None:
     node.rename_attribute('typ', 'type')
     node.unders_to_dashes_in_keys()
Beispiel #3
0
 def _yatiml_savorize(cls, node: yatiml.Node) -> None:
     node.dashes_to_unders_in_keys()
     node.rename_attribute('type', 'typ')