|
@@ -55,6 +55,13 @@ def get_model_list(location):
|
|
|
def compare_locations(location, extra_to_default):
|
|
|
assert model_list(location) == get_model_list(location) | set(extra_to_default)
|
|
|
|
|
|
+def compare_unordered_lists(got, expected):
|
|
|
+ assert len(got) == len(expected)
|
|
|
+ for i in got:
|
|
|
+ assert i in expected
|
|
|
+ for i in expected:
|
|
|
+ assert i in got
|
|
|
+
|
|
|
class TestModelverseCore(unittest.TestCase):
|
|
|
def setUp(self):
|
|
|
self.proc, self.address = start_mvc()
|
|
@@ -386,7 +393,9 @@ class TestModelverseCore(unittest.TestCase):
|
|
|
|
|
|
alter_context("formalisms/PetriNet", "formalisms/SimpleClassDiagrams")
|
|
|
alter_context("models/my_pn", "formalisms/PetriNet")
|
|
|
- element_list_nice("formalisms/PetriNet") == \
|
|
|
+
|
|
|
+ got = element_list_nice("formalisms/PetriNet")
|
|
|
+ expected = \
|
|
|
[{'id': 'Natural', 'type': 'SimpleAttribute', 'constraint': None},
|
|
|
{'id': 'String', 'type': 'SimpleAttribute', 'constraint': None},
|
|
|
{'id': 'Place', 'type': 'Class', 'lower_cardinality': None, 'upper_cardinality': None, 'constraint': None},
|
|
@@ -399,8 +408,10 @@ class TestModelverseCore(unittest.TestCase):
|
|
|
{'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}
|
|
|
]
|
|
|
+ compare_unordered_lists(got, expected)
|
|
|
|
|
|
- element_list_nice("models/my_pn") == \
|
|
|
+ got = element_list_nice("models/my_pn")
|
|
|
+ expected = \
|
|
|
[{'id': 'p1', 'type': 'Place', 'tokens': 1, 'name': 'p1'},
|
|
|
{'id': 'p2', 'type': 'Place', 'tokens': 2, 'name': 'p2'},
|
|
|
{'id': 'p3', 'type': 'Place', 'tokens': 3, 'name': 'p3'},
|
|
@@ -409,30 +420,36 @@ class TestModelverseCore(unittest.TestCase):
|
|
|
{'id': '__1', 'type': 'P2T', '__source': 'p2', '__target': 't1', 'weight': 1},
|
|
|
{'id': '__2', 'type': 'T2P', '__source': 't1', '__target': 'p3', 'weight': 2}
|
|
|
]
|
|
|
+ compare_unordered_lists(got, expected)
|
|
|
|
|
|
alter_context("formalisms/PetriNet", "formalisms/Bottom")
|
|
|
alter_context("models/my_pn", "formalisms/Bottom")
|
|
|
|
|
|
- count = 0
|
|
|
+ count_nodes = 0
|
|
|
+ count_edges = 0
|
|
|
for entry in element_list_nice("formalisms/PetriNet"):
|
|
|
assert entry["type"] in ["Node", "Edge"]
|
|
|
if entry["type"] == "Node":
|
|
|
assert len(entry) == 2
|
|
|
+ count_nodes += 1
|
|
|
else:
|
|
|
assert len(entry) == 4
|
|
|
- count += 1
|
|
|
- #TODO be more specific here
|
|
|
- assert count > 1
|
|
|
+ count_edges += 1
|
|
|
+ assert count_nodes == 14
|
|
|
+ assert count_edges == 17
|
|
|
|
|
|
- count = 0
|
|
|
+ count_nodes = 0
|
|
|
+ count_edges = 0
|
|
|
for entry in element_list_nice("models/my_pn"):
|
|
|
assert entry["type"] in ["Node", "Edge"]
|
|
|
if entry["type"] == "Node":
|
|
|
assert len(entry) == 2
|
|
|
+ count_nodes += 1
|
|
|
else:
|
|
|
assert len(entry) == 4
|
|
|
- #TODO be more specific here
|
|
|
- assert count > 1
|
|
|
+ count_edges += 1
|
|
|
+ assert count_nodes == 14
|
|
|
+ assert count_edges == 13
|
|
|
|
|
|
alter_context("formalisms/PetriNet", "formalisms/PetriNet")
|
|
|
alter_context("models/my_pn", "formalisms/SimpleClassDiagrams")
|