|
|
@@ -662,6 +662,107 @@ class TestModelverse(unittest.TestCase):
|
|
|
except ReadPermissionDenied:
|
|
|
pass
|
|
|
|
|
|
+ def test_op_element_list_nice(self):
|
|
|
+ # Test simple element_list_nice
|
|
|
+ model_add("users/user/test/a", "formalisms/ProcessModel", """
|
|
|
+ Start start {}
|
|
|
+ Finish finish {}
|
|
|
+ Next nxt (start, finish) {}
|
|
|
+ """)
|
|
|
+
|
|
|
+ # Basic operation
|
|
|
+ lst = element_list_nice("users/user/test/a")
|
|
|
+ assert len(lst) == 3
|
|
|
+ assert {"__id": "start", "__type": "Start"} in lst
|
|
|
+ assert {"__id": "finish", "__type": "Finish"} in lst
|
|
|
+ assert {"__id": "nxt", "__type": "Next", "__source": "start", "__target": "finish"} in lst
|
|
|
+
|
|
|
+ # Test a model with attributes
|
|
|
+ model_add("users/user/test/b", "formalisms/ProcessModel", """
|
|
|
+ Start start {}
|
|
|
+ Exec exec1 {
|
|
|
+ name = "first exec"
|
|
|
+ }
|
|
|
+ Finish finish {}
|
|
|
+
|
|
|
+ Data d1 {
|
|
|
+ name = "data 1"
|
|
|
+ type = "type 1"
|
|
|
+ }
|
|
|
+
|
|
|
+ Next n1 (start, exec1) {}
|
|
|
+ Next n2 (exec1, finish) {}
|
|
|
+
|
|
|
+ Produces p1 (exec1, d1) {
|
|
|
+ name = "producer"
|
|
|
+ }
|
|
|
+ """)
|
|
|
+ lst = element_list_nice("users/user/test/b")
|
|
|
+ assert len(lst) == 7
|
|
|
+ assert {"__id": "start", "__type": "Start"} in lst
|
|
|
+ assert {"__id": "finish", "__type": "Finish"} in lst
|
|
|
+ assert {"__id": "exec1", "__type": "Exec", "name": "first exec"} in lst
|
|
|
+ assert {"__id": "d1", "__type": "Data", "name": "data 1", "type": "type 1"} in lst
|
|
|
+ assert {"__id": "n1", "__type": "Next", "__source": "start", "__target": "exec1"} in lst
|
|
|
+ assert {"__id": "n2", "__type": "Next", "__source": "exec1", "__target": "finish"} in lst
|
|
|
+ assert {"__id": "p1", "__type": "Produces", "__source": "exec1", "__target": "d1", "name": "producer"} in lst
|
|
|
+
|
|
|
+ # Try one with defined attributes
|
|
|
+ model_add("users/user/test/c", "formalisms/SimpleClassDiagrams", """
|
|
|
+ SimpleAttribute Natural {
|
|
|
+ name = "natural"
|
|
|
+ }
|
|
|
+ SimpleAttribute String {
|
|
|
+ name = "string"
|
|
|
+ }
|
|
|
+
|
|
|
+ Class place {
|
|
|
+ name = "Place"
|
|
|
+ name : String
|
|
|
+ capacity : Natural
|
|
|
+ }
|
|
|
+ Class transition {
|
|
|
+ name = "Transition"
|
|
|
+ name : String
|
|
|
+ }
|
|
|
+ Association p2t (place, transition) {
|
|
|
+ name = "P2T"
|
|
|
+ weight : Natural
|
|
|
+ }
|
|
|
+ Association t2p (transition, place) {
|
|
|
+ name = "T2P"
|
|
|
+ weight : Natural
|
|
|
+ }
|
|
|
+ """)
|
|
|
+
|
|
|
+ lst = element_list_nice("users/user/test/c")
|
|
|
+ assert len(lst) == 11
|
|
|
+ assert {"__id": "Natural", "__type": "SimpleAttribute", "constraint": {"AL": ""}, "name": "natural"} in lst
|
|
|
+ assert {"__id": "String", "__type": "SimpleAttribute", "constraint": {"AL": ""}, "name": "string"} in lst
|
|
|
+ assert {"__id": "place", "name": "Place", "__type": "Class", "constraint": {"AL": ""}, "lower_cardinality": None, "upper_cardinality": None, "abstract": None} in lst
|
|
|
+ assert {"__id": "transition", "name": "Transition", "__type": "Class", "constraint": {"AL": ""}, "lower_cardinality": None, "upper_cardinality": None, "abstract": None} in lst
|
|
|
+ assert {"__id": "p2t", "name": "P2T", "__type": "Association", "__source": "place", "__target": "transition", "constraint": {"AL": ""}, "source_lower_cardinality": None, "source_upper_cardinality": None, "target_lower_cardinality": None, "target_upper_cardinality": None} in lst
|
|
|
+ assert {"__id": "t2p", "name": "T2P", "__type": "Association", "__source": "transition", "__target": "place", "constraint": {"AL": ""}, "source_lower_cardinality": None, "source_upper_cardinality": None, "target_lower_cardinality": None, "target_upper_cardinality": None} in lst
|
|
|
+ assert {"__id": "place_name", "__type": "AttributeLink", "__source": "place", "__target": "String", "name": "name", "optional": False, "constraint": {"AL": ""}} in lst
|
|
|
+ assert {"__id": "place_capacity", "__type": "AttributeLink", "__source": "place", "__target": "Natural", "name": "capacity", "optional": False, "constraint": {"AL": ""}} in lst
|
|
|
+ assert {"__id": "transition_name", "__type": "AttributeLink", "__source": "transition", "__target": "String", "name": "name", "optional": False, "constraint": {"AL": ""}} in lst
|
|
|
+ assert {"__id": "p2t_weight", "__type": "AttributeLink", "__source": "p2t", "__target": "Natural", "name": "weight", "optional": False, "constraint": {"AL": ""}} in lst
|
|
|
+ assert {"__id": "t2p_weight", "__type": "AttributeLink", "__source": "t2p", "__target": "Natural", "name": "weight", "optional": False, "constraint": {"AL": ""}} in lst
|
|
|
+
|
|
|
+ # Try on non-existing model
|
|
|
+ try:
|
|
|
+ element_list_nice("a")
|
|
|
+ self.fail()
|
|
|
+ except UnknownModel:
|
|
|
+ pass
|
|
|
+
|
|
|
+ # Try a non-readable model
|
|
|
+ try:
|
|
|
+ element_list_nice("administration/core")
|
|
|
+ self.fail()
|
|
|
+ except ReadPermissionDenied:
|
|
|
+ pass
|
|
|
+
|
|
|
"""
|
|
|
def test_op_model_render(self):
|
|
|
def test_op_transformation_between(self):
|
|
|
@@ -684,7 +785,6 @@ class TestModelverse(unittest.TestCase):
|
|
|
def test_op_group_list(self):
|
|
|
def test_op_conformance_delete(self):
|
|
|
def test_op_conformance_add(self):
|
|
|
- def test_op_element_list_nice(self):
|
|
|
def test_op_types(self):
|
|
|
def test_op_types_full(self):
|
|
|
def test_op_read_info(self):
|