Example #1
0
def test_map_attribute_to_seq(class_node: yatiml.Node) -> None:
    assert class_node.has_attribute_type('dict1', dict)

    class_node.map_attribute_to_seq('dict1', 'item_id', 'price')

    assert class_node.has_attribute_type('dict1', list)
    attr_node = class_node.get_attribute('dict1')

    assert len(attr_node.seq_items()) == 3
    first_item_node = attr_node.seq_items()[0]
    assert first_item_node.has_attribute('item_id')
    assert first_item_node.has_attribute('price')
    first_item_id = first_item_node.get_attribute('item_id').get_value()

    second_item_node = attr_node.seq_items()[1]
    assert second_item_node.has_attribute('item_id')
    assert second_item_node.has_attribute('price')
    second_item_id = second_item_node.get_attribute('item_id').get_value()

    third_item_node = attr_node.seq_items()[2]
    assert third_item_node.has_attribute('item_id')
    assert third_item_node.has_attribute('price')
    third_item_id = third_item_node.get_attribute('item_id').get_value()

    assert first_item_id == 'item1'
    assert second_item_id == 'item2'
    assert third_item_id == 'item3'

    assert ((first_item_id == 'item1' and second_item_id == 'item2')
            or (first_item_id == 'item2' and second_item_id == 'item1'))
Example #2
0
 def _yatiml_savorize(cls, node: yatiml.Node) -> None:
     node.map_attribute_to_seq('components', 'name', 'implementation')
     node.map_attribute_to_seq('conduits', 'sender', 'receiver')