|
@@ -386,28 +386,63 @@ class TestModelverseCore(unittest.TestCase):
|
|
|
|
|
|
alter_context("formalisms/PetriNet", "formalisms/SimpleClassDiagrams")
|
|
|
alter_context("models/my_pn", "formalisms/PetriNet")
|
|
|
- print(element_list_nice("formalisms/PetriNet"))
|
|
|
- print(element_list_nice("models/my_pn"))
|
|
|
+ element_list_nice("formalisms/PetriNet") == \
|
|
|
+ [{'id': 'Natural', 'type': 'SimpleAttribute', 'constraint': None},
|
|
|
+ {'id': 'String', 'type': 'SimpleAttribute', 'constraint': None},
|
|
|
+ {'id': 'Place', 'type': 'Class', 'lower_cardinality': None, 'upper_cardinality': None, 'constraint': None},
|
|
|
+ {'id': 'Place_tokens', 'type': 'AttributeLink', '__source': 'Place', '__target': 'Natural', 'name': 'tokens', 'optional': False, 'constraint': None},
|
|
|
+ {'id': 'Place_name', 'type': 'AttributeLink', '__source': 'Place', '__target': 'String', 'name': 'name', 'optional': False, 'constraint': None},
|
|
|
+ {'id': 'Transition', 'type': 'Class', 'lower_cardinality': None, 'upper_cardinality': None, 'constraint': None},
|
|
|
+ {'id': 'Transition_name', 'type': 'AttributeLink', '__source': 'Transition', '__target': 'String', 'name': 'name', 'optional': False, 'constraint': None},
|
|
|
+ {'id': 'P2T', 'type': 'Association', '__source': 'Place', '__target': 'Transition', 'source_lower_cardinality': None, 'target_lower_cardinality': None, 'source_upper_cardinality': None, 'target_upper_cardinality': None, 'constraint': None},
|
|
|
+ {'id': 'P2T_weight', 'type': 'AttributeLink', '__source': 'P2T', '__target': 'Natural', 'name': 'weight', 'optional': False, 'constraint': None},
|
|
|
+ {'id': 'T2P', 'type': 'Association', '__source': 'Transition', '__target': 'Place', 'source_lower_cardinality': None, 'target_lower_cardinality': None, 'source_upper_cardinality': None, 'target_upper_cardinality': None, 'constraint': None},
|
|
|
+ {'id': 'T2P_weight', 'type': 'AttributeLink', '__source': 'T2P', '__target': 'Natural', 'name': 'weight', 'optional': False, 'constraint': None}
|
|
|
+ ]
|
|
|
+
|
|
|
+ element_list_nice("models/my_pn") == \
|
|
|
+ [{'id': 'p1', 'type': 'Place', 'tokens': 1, 'name': 'p1'},
|
|
|
+ {'id': 'p2', 'type': 'Place', 'tokens': 2, 'name': 'p2'},
|
|
|
+ {'id': 'p3', 'type': 'Place', 'tokens': 3, 'name': 'p3'},
|
|
|
+ {'id': 't1', 'type': 'Transition', 'name': 't1'},
|
|
|
+ {'id': '__0', 'type': 'P2T', '__source': 'p1', '__target': 't1', 'weight': 1},
|
|
|
+ {'id': '__1', 'type': 'P2T', '__source': 'p2', '__target': 't1', 'weight': 1},
|
|
|
+ {'id': '__2', 'type': 'T2P', '__source': 't1', '__target': 'p3', 'weight': 2}
|
|
|
+ ]
|
|
|
|
|
|
alter_context("formalisms/PetriNet", "formalisms/Bottom")
|
|
|
alter_context("models/my_pn", "formalisms/Bottom")
|
|
|
- print(element_list_nice("formalisms/PetriNet"))
|
|
|
- print(element_list_nice("models/my_pn"))
|
|
|
|
|
|
- alter_context("formalisms/PetriNet", "formalisms/SimpleClassDiagrams")
|
|
|
- alter_context("models/my_pn", "formalisms/PetriNet")
|
|
|
- print(element_list_nice("formalisms/PetriNet"))
|
|
|
- print(element_list_nice("models/my_pn"))
|
|
|
+ count = 0
|
|
|
+ for entry in element_list_nice("formalisms/PetriNet"):
|
|
|
+ assert entry["type"] in ["Node", "Edge"]
|
|
|
+ if entry["type"] == "Node":
|
|
|
+ assert len(entry) == 2
|
|
|
+ else:
|
|
|
+ assert len(entry) == 4
|
|
|
+ count += 1
|
|
|
+ #TODO be more specific here
|
|
|
+ assert count > 1
|
|
|
+
|
|
|
+ count = 0
|
|
|
+ for entry in element_list_nice("models/my_pn"):
|
|
|
+ assert entry["type"] in ["Node", "Edge"]
|
|
|
+ if entry["type"] == "Node":
|
|
|
+ assert len(entry) == 2
|
|
|
+ else:
|
|
|
+ assert len(entry) == 4
|
|
|
+ #TODO be more specific here
|
|
|
+ assert count > 1
|
|
|
|
|
|
alter_context("formalisms/PetriNet", "formalisms/PetriNet")
|
|
|
alter_context("models/my_pn", "formalisms/SimpleClassDiagrams")
|
|
|
try:
|
|
|
- print(element_list_nice("formalisms/PetriNet"))
|
|
|
+ element_list_nice("formalisms/PetriNet")
|
|
|
self.fail()
|
|
|
except:
|
|
|
pass
|
|
|
try:
|
|
|
- print(element_list_nice("models/my_pn"))
|
|
|
+ element_list_nice("models/my_pn")
|
|
|
self.fail()
|
|
|
except:
|
|
|
pass
|