|
@@ -148,6 +148,12 @@ class TestModelverse(unittest.TestCase):
|
|
|
# Try model list of a model itself
|
|
|
assert model_list("formalisms/SimpleClassDiagrams") == set([])
|
|
|
|
|
|
+ model_add("users/user/test/a", "formalisms/SimpleClassDiagrams")
|
|
|
+ model_add("users/user/test/b", "formalisms/SimpleClassDiagrams")
|
|
|
+ model_add("users/user/test/c", "formalisms/SimpleClassDiagrams")
|
|
|
+ assert model_list("users/user/test") == set(["a", "b", "c"])
|
|
|
+ assert model_list("users/user/test/") == set(["a", "b", "c"])
|
|
|
+
|
|
|
def test_op_model_list_full(self):
|
|
|
assert model_list_full("") == set([("formalisms/", "admin", "admin", "221"),
|
|
|
("models/", "admin", "admin", "221"),
|
|
@@ -3805,15 +3811,31 @@ class TestModelverse(unittest.TestCase):
|
|
|
}
|
|
|
""")
|
|
|
|
|
|
- print("Finish model add")
|
|
|
-
|
|
|
# Add a transformation with normal signature
|
|
|
transformation_add_MANUAL({"MODEL_A": "users/user/test/A"}, {"MODEL_B": "users/user/test/B"}, "users/user/test/c")
|
|
|
- print("Added manual 1")
|
|
|
+
|
|
|
+ # Add a transformation with normal signature and merged metamodel changes
|
|
|
+ def operation(model):
|
|
|
+ # Check if both are present
|
|
|
+ lst = element_list_nice(model)
|
|
|
+ print(lst)
|
|
|
+
|
|
|
+ # Do minor merge operation
|
|
|
+ instantiate(model, "Association", edge=("MODEL_A/A", "MODEL_B/B"))
|
|
|
+
|
|
|
+ transformation_add_MANUAL({"MODEL_A": "users/user/test/A"}, {"MODEL_B": "users/user/test/B"}, "users/user/test/d", operation)
|
|
|
|
|
|
# Add a transformation with empty signature
|
|
|
- transformation_add_MANUAL({}, {}, "users/user/test/d")
|
|
|
- print("Added manual 2")
|
|
|
+ transformation_add_MANUAL({}, {}, "users/user/test/g")
|
|
|
+
|
|
|
+ # Add a transformation with empty signature and a callback
|
|
|
+ try:
|
|
|
+ def operation(model):
|
|
|
+ pass
|
|
|
+ transformation_add_MANUAL({}, {}, "users/user/test/h", operation)
|
|
|
+ self.fail()
|
|
|
+ except CallbackOnEmptySignature:
|
|
|
+ assert "h" not in model_list("users/user/test")
|
|
|
|
|
|
def operation(model):
|
|
|
# Check if model correctly loaded with names rewritten
|
|
@@ -3837,6 +3859,7 @@ class TestModelverse(unittest.TestCase):
|
|
|
assert {"__id": "MODEL_A/def", "__type": "MODEL_A/A", "name": "2"} in lst
|
|
|
assert {"__id": "test_value", "__type": "MODEL_B/B", "name": "5"} in lst
|
|
|
|
|
|
+ # Do operation with a callback
|
|
|
transformation_execute_MANUAL("users/user/test/c", {"MODEL_A": "users/user/test/a"}, {"MODEL_B": "users/user/test/a_2"}, operation)
|
|
|
|
|
|
# Check that users/user/test/a was NOT modified, as it was not part of the output signature
|
|
@@ -3857,8 +3880,6 @@ class TestModelverse(unittest.TestCase):
|
|
|
assert len(lst) == 1
|
|
|
assert {"__id": "test_value", "__type": "B", "name": "5"} in lst
|
|
|
|
|
|
- # Do transformation
|
|
|
-
|
|
|
"""
|
|
|
def test_op_model_render(self):
|
|
|
def test_op_transformation_add_MT(self):
|