|
@@ -3562,6 +3562,219 @@ class TestModelverse(unittest.TestCase):
|
|
|
except NotAModel:
|
|
|
pass
|
|
|
|
|
|
+ def test_op_transformation_between_MANUAL(self):
|
|
|
+ # Add set of transformations
|
|
|
+ def create_transf(name, inputs, outputs):
|
|
|
+ transformation_add_MANUAL({"key_%s" % i: "users/user/test/" + i for i in inputs}, {"key_%s" % i: "users/user/test/" + i for i in outputs}, "users/user/test/" + name)
|
|
|
+
|
|
|
+ model_add("users/user/test/A", "formalisms/SimpleClassDiagrams")
|
|
|
+ model_add("users/user/test/B", "formalisms/SimpleClassDiagrams")
|
|
|
+ model_add("users/user/test/C", "formalisms/SimpleClassDiagrams")
|
|
|
+ model_add("users/user/test/D", "formalisms/SimpleClassDiagrams")
|
|
|
+ model_add("users/user/test/E", "formalisms/SimpleClassDiagrams")
|
|
|
+
|
|
|
+ create_transf("1", ["A"], ["B"])
|
|
|
+ create_transf("2", ["A"], ["C", "D"])
|
|
|
+ create_transf("3", ["B", "C"], ["D"])
|
|
|
+ create_transf("4", ["A", "B"], ["D", "E"])
|
|
|
+
|
|
|
+ # Test normal operation
|
|
|
+ def check_transformations(inputs, outputs, expected):
|
|
|
+ assert transformation_between({"key_" + i: "users/user/test/" + i for i in inputs}, {"key_" + i: "users/user/test/" + i for i in outputs}) == set(["users/user/test/" + i for i in expected])
|
|
|
+
|
|
|
+ # Obvious ones, with a perfect signature match
|
|
|
+ check_transformations(["A"], ["B"], ["1"])
|
|
|
+ check_transformations(["A"], ["C", "D"], ["2"])
|
|
|
+ check_transformations(["B", "C"], ["D"], ["3"])
|
|
|
+ check_transformations(["A", "B"], ["D", "E"], ["4"])
|
|
|
+
|
|
|
+ # Incomplete matches
|
|
|
+ check_transformations(["A"], [], ["1", "2", "4"])
|
|
|
+ check_transformations(["B"], [], ["3", "4"])
|
|
|
+ check_transformations(["C"], [], ["3"])
|
|
|
+ check_transformations(["D"], [], [])
|
|
|
+ check_transformations(["E"], [], [])
|
|
|
+ check_transformations([], ["A"], [])
|
|
|
+ check_transformations([], ["B"], ["1"])
|
|
|
+ check_transformations([], ["C"], ["2"])
|
|
|
+ check_transformations([], ["D"], ["2", "3", "4"])
|
|
|
+ check_transformations([], ["E"], ["4"])
|
|
|
+
|
|
|
+ # Complete match, which doesn't return as it would give all transformations in the Modelverse...
|
|
|
+ try:
|
|
|
+ check_transformations([], [], [])
|
|
|
+ self.fail()
|
|
|
+ except IncorrectFormat:
|
|
|
+ pass
|
|
|
+
|
|
|
+ # Non-existing model (source)
|
|
|
+ try:
|
|
|
+ assert transformation_between({"key_A": "users/user/test/Z"}, {"key_B": "users/user/test/B"}) == set([])
|
|
|
+ self.fail()
|
|
|
+ except UnknownModel:
|
|
|
+ pass
|
|
|
+
|
|
|
+ # Key mismatch (source)
|
|
|
+ assert transformation_between({"key_B": "users/user/test/A"}, {"key_B": "users/user/test/B"}) == set([])
|
|
|
+
|
|
|
+ # Model mismatch (source)
|
|
|
+ assert transformation_between({"key_A": "users/user/test/B"}, {"key_B": "users/user/test/B"}) == set([])
|
|
|
+
|
|
|
+ # Non-existing model (target)
|
|
|
+ try:
|
|
|
+ assert transformation_between({"key_A": "users/user/test/A"}, {"key_B": "users/user/test/Z"}) == set([])
|
|
|
+ self.fail()
|
|
|
+ except UnknownModel:
|
|
|
+ pass
|
|
|
+
|
|
|
+ # Key mismatch (target)
|
|
|
+ assert transformation_between({"key_A": "users/user/test/A"}, {"key_A": "users/user/test/B"}) == set([])
|
|
|
+
|
|
|
+ # Model mismatch (target)
|
|
|
+ assert transformation_between({"key_A": "users/user/test/A"}, {"key_B": "users/user/test/A"}) == set([])
|
|
|
+
|
|
|
+ def test_op_transformation_between_AL(self):
|
|
|
+ # Add set of transformations
|
|
|
+ def create_transf(name, inputs, outputs):
|
|
|
+ transformation_add_AL({"key_%s" % i: "users/user/test/" + i for i in inputs}, {"key_%s" % i: "users/user/test/" + i for i in outputs}, "users/user/test/" + name, "Void function main():\n\treturn!")
|
|
|
+
|
|
|
+ model_add("users/user/test/A", "formalisms/SimpleClassDiagrams")
|
|
|
+ model_add("users/user/test/B", "formalisms/SimpleClassDiagrams")
|
|
|
+ model_add("users/user/test/C", "formalisms/SimpleClassDiagrams")
|
|
|
+ model_add("users/user/test/D", "formalisms/SimpleClassDiagrams")
|
|
|
+ model_add("users/user/test/E", "formalisms/SimpleClassDiagrams")
|
|
|
+
|
|
|
+ create_transf("1", ["A"], ["B"])
|
|
|
+ create_transf("2", ["A"], ["C", "D"])
|
|
|
+ create_transf("3", ["B", "C"], ["D"])
|
|
|
+ create_transf("4", ["A", "B"], ["D", "E"])
|
|
|
+
|
|
|
+ # Test normal operation
|
|
|
+ def check_transformations(inputs, outputs, expected):
|
|
|
+ assert transformation_between({"key_" + i: "users/user/test/" + i for i in inputs}, {"key_" + i: "users/user/test/" + i for i in outputs}) == set(["users/user/test/" + i for i in expected])
|
|
|
+
|
|
|
+ # Obvious ones, with a perfect signature match
|
|
|
+ check_transformations(["A"], ["B"], ["1"])
|
|
|
+ check_transformations(["A"], ["C", "D"], ["2"])
|
|
|
+ check_transformations(["B", "C"], ["D"], ["3"])
|
|
|
+ check_transformations(["A", "B"], ["D", "E"], ["4"])
|
|
|
+
|
|
|
+ # Incomplete matches
|
|
|
+ check_transformations(["A"], [], ["1", "2", "4"])
|
|
|
+ check_transformations(["B"], [], ["3", "4"])
|
|
|
+ check_transformations(["C"], [], ["3"])
|
|
|
+ check_transformations(["D"], [], [])
|
|
|
+ check_transformations(["E"], [], [])
|
|
|
+ check_transformations([], ["A"], [])
|
|
|
+ check_transformations([], ["B"], ["1"])
|
|
|
+ check_transformations([], ["C"], ["2"])
|
|
|
+ check_transformations([], ["D"], ["2", "3", "4"])
|
|
|
+ check_transformations([], ["E"], ["4"])
|
|
|
+
|
|
|
+ # Complete match, which doesn't return as it would give all transformations in the Modelverse...
|
|
|
+ try:
|
|
|
+ check_transformations([], [], [])
|
|
|
+ self.fail()
|
|
|
+ except IncorrectFormat:
|
|
|
+ pass
|
|
|
+
|
|
|
+ # Non-existing model (source)
|
|
|
+ try:
|
|
|
+ assert transformation_between({"key_A": "users/user/test/Z"}, {"key_B": "users/user/test/B"}) == set([])
|
|
|
+ self.fail()
|
|
|
+ except UnknownModel:
|
|
|
+ pass
|
|
|
+
|
|
|
+ # Key mismatch (source)
|
|
|
+ assert transformation_between({"key_B": "users/user/test/A"}, {"key_B": "users/user/test/B"}) == set([])
|
|
|
+
|
|
|
+ # Model mismatch (source)
|
|
|
+ assert transformation_between({"key_A": "users/user/test/B"}, {"key_B": "users/user/test/B"}) == set([])
|
|
|
+
|
|
|
+ # Non-existing model (target)
|
|
|
+ try:
|
|
|
+ assert transformation_between({"key_A": "users/user/test/A"}, {"key_B": "users/user/test/Z"}) == set([])
|
|
|
+ self.fail()
|
|
|
+ except UnknownModel:
|
|
|
+ pass
|
|
|
+
|
|
|
+ # Key mismatch (target)
|
|
|
+ assert transformation_between({"key_A": "users/user/test/A"}, {"key_A": "users/user/test/B"}) == set([])
|
|
|
+
|
|
|
+ # Model mismatch (target)
|
|
|
+ assert transformation_between({"key_A": "users/user/test/A"}, {"key_B": "users/user/test/A"}) == set([])
|
|
|
+
|
|
|
+ def test_op_transformation_between_MT(self):
|
|
|
+ # Add set of transformations
|
|
|
+ def create_transf(name, inputs, outputs):
|
|
|
+ transformation_add_MT({"key_%s" % i: "users/user/test/" + i for i in inputs}, {"key_%s" % i: "users/user/test/" + i for i in outputs}, "users/user/test/" + name, "Composite a{}")
|
|
|
+
|
|
|
+ model_add("users/user/test/A", "formalisms/SimpleClassDiagrams")
|
|
|
+ model_add("users/user/test/B", "formalisms/SimpleClassDiagrams")
|
|
|
+ model_add("users/user/test/C", "formalisms/SimpleClassDiagrams")
|
|
|
+ model_add("users/user/test/D", "formalisms/SimpleClassDiagrams")
|
|
|
+ model_add("users/user/test/E", "formalisms/SimpleClassDiagrams")
|
|
|
+
|
|
|
+ create_transf("1", ["A"], ["B"])
|
|
|
+ create_transf("2", ["A"], ["C", "D"])
|
|
|
+ create_transf("3", ["B", "C"], ["D"])
|
|
|
+ create_transf("4", ["A", "B"], ["D", "E"])
|
|
|
+
|
|
|
+ # Test normal operation
|
|
|
+ def check_transformations(inputs, outputs, expected):
|
|
|
+ assert transformation_between({"key_" + i: "users/user/test/" + i for i in inputs}, {"key_" + i: "users/user/test/" + i for i in outputs}) == set(["users/user/test/" + i for i in expected])
|
|
|
+
|
|
|
+ # Obvious ones, with a perfect signature match
|
|
|
+ check_transformations(["A"], ["B"], ["1"])
|
|
|
+ check_transformations(["A"], ["C", "D"], ["2"])
|
|
|
+ check_transformations(["B", "C"], ["D"], ["3"])
|
|
|
+ check_transformations(["A", "B"], ["D", "E"], ["4"])
|
|
|
+
|
|
|
+ # Incomplete matches
|
|
|
+ check_transformations(["A"], [], ["1", "2", "4"])
|
|
|
+ check_transformations(["B"], [], ["3", "4"])
|
|
|
+ check_transformations(["C"], [], ["3"])
|
|
|
+ check_transformations(["D"], [], [])
|
|
|
+ check_transformations(["E"], [], [])
|
|
|
+ check_transformations([], ["A"], [])
|
|
|
+ check_transformations([], ["B"], ["1"])
|
|
|
+ check_transformations([], ["C"], ["2"])
|
|
|
+ check_transformations([], ["D"], ["2", "3", "4"])
|
|
|
+ check_transformations([], ["E"], ["4"])
|
|
|
+
|
|
|
+ # Complete match, which doesn't return as it would give all transformations in the Modelverse...
|
|
|
+ try:
|
|
|
+ check_transformations([], [], [])
|
|
|
+ self.fail()
|
|
|
+ except IncorrectFormat:
|
|
|
+ pass
|
|
|
+
|
|
|
+ # Non-existing model (source)
|
|
|
+ try:
|
|
|
+ assert transformation_between({"key_A": "users/user/test/Z"}, {"key_B": "users/user/test/B"}) == set([])
|
|
|
+ self.fail()
|
|
|
+ except UnknownModel:
|
|
|
+ pass
|
|
|
+
|
|
|
+ # Key mismatch (source)
|
|
|
+ assert transformation_between({"key_B": "users/user/test/A"}, {"key_B": "users/user/test/B"}) == set([])
|
|
|
+
|
|
|
+ # Model mismatch (source)
|
|
|
+ assert transformation_between({"key_A": "users/user/test/B"}, {"key_B": "users/user/test/B"}) == set([])
|
|
|
+
|
|
|
+ # Non-existing model (target)
|
|
|
+ try:
|
|
|
+ assert transformation_between({"key_A": "users/user/test/A"}, {"key_B": "users/user/test/Z"}) == set([])
|
|
|
+ self.fail()
|
|
|
+ except UnknownModel:
|
|
|
+ pass
|
|
|
+
|
|
|
+ # Key mismatch (target)
|
|
|
+ assert transformation_between({"key_A": "users/user/test/A"}, {"key_A": "users/user/test/B"}) == set([])
|
|
|
+
|
|
|
+ # Model mismatch (target)
|
|
|
+ assert transformation_between({"key_A": "users/user/test/A"}, {"key_B": "users/user/test/A"}) == set([])
|
|
|
+
|
|
|
"""
|
|
|
def test_op_model_render(self):
|
|
|
def test_op_transformation_between(self):
|