|
@@ -3081,6 +3081,144 @@ class TestModelverse(unittest.TestCase):
|
|
|
except UnknownModel:
|
|
|
assert model_types("users/user/test/b") == before
|
|
|
|
|
|
+ def test_op_conformance_delete(self):
|
|
|
+ model_add("users/user/test/a", "formalisms/SimpleClassDiagrams", """
|
|
|
+ Class A {}
|
|
|
+ Class B {}
|
|
|
+ Association C (A, B) {}
|
|
|
+ """)
|
|
|
+
|
|
|
+ # Add conformance bottom relation
|
|
|
+ conformance_add("users/user/test/a", "formalisms/Bottom")
|
|
|
+
|
|
|
+ # Verify initial state
|
|
|
+ ts = model_types("users/user/test/a")
|
|
|
+ assert len(ts) == 2
|
|
|
+ while ts:
|
|
|
+ t = ts.pop()
|
|
|
+ assert t[0] in ["formalisms/SimpleClassDiagrams", "formalisms/Bottom"]
|
|
|
+ if t[0] == "formalisms/SimpleClassDiagrams":
|
|
|
+ assert t[1] != None
|
|
|
+ elif t[1] == "formalisms/Bottom":
|
|
|
+ # Type mapping is empty
|
|
|
+ assert t[1] == None
|
|
|
+ assert t[2] == None
|
|
|
+
|
|
|
+ # Now remove it again
|
|
|
+ conformance_delete("users/user/test/a", "formalisms/Bottom", "")
|
|
|
+ ts = model_types("users/user/test/a")
|
|
|
+ assert len(ts) == 1
|
|
|
+ t = ts.pop()
|
|
|
+ assert t[0] == "formalisms/SimpleClassDiagrams"
|
|
|
+ assert t[1] != None
|
|
|
+ assert t[2] == None
|
|
|
+
|
|
|
+ # Add conformance bottom relation twice
|
|
|
+ conformance_add("users/user/test/a", "formalisms/Bottom")
|
|
|
+ conformance_add("users/user/test/a", "formalisms/Bottom")
|
|
|
+
|
|
|
+ # Should be there twice, but set flattens it to once
|
|
|
+ ts = model_types("users/user/test/a")
|
|
|
+ assert len(ts) == 2
|
|
|
+ while ts:
|
|
|
+ t = ts.pop()
|
|
|
+ assert t[0] in ["formalisms/SimpleClassDiagrams", "formalisms/Bottom"]
|
|
|
+ if t[0] == "formalisms/SimpleClassDiagrams":
|
|
|
+ assert t[1] != None
|
|
|
+ elif t[1] == "formalisms/Bottom":
|
|
|
+ # Type mapping is empty
|
|
|
+ assert t[1] == None
|
|
|
+ assert t[2] == None
|
|
|
+
|
|
|
+ # Now remove it (once called, but invoked for all occurences!)
|
|
|
+ conformance_delete("users/user/test/a", "formalisms/Bottom", "")
|
|
|
+
|
|
|
+ ts = model_types("users/user/test/a")
|
|
|
+ assert len(ts) == 1
|
|
|
+ t = ts.pop()
|
|
|
+ assert t[0] == "formalisms/SimpleClassDiagrams"
|
|
|
+ assert t[1] != None
|
|
|
+ assert t[2] == None
|
|
|
+
|
|
|
+ # Now actually test filtering capabilities
|
|
|
+ alter_context("users/user/test/a", "formalisms/Bottom")
|
|
|
+ element_list("users/user/test/a")
|
|
|
+ alter_context("users/user/test/a", "formalisms/SimpleClassDiagrams")
|
|
|
+
|
|
|
+ # Model should be there with a type mapping model
|
|
|
+ ts = model_types("users/user/test/a")
|
|
|
+ assert len(ts) == 2
|
|
|
+ while ts:
|
|
|
+ t = ts.pop()
|
|
|
+ assert t[0] in ["formalisms/SimpleClassDiagrams", "formalisms/Bottom"]
|
|
|
+ assert t[1] != None
|
|
|
+ assert t[2] == None
|
|
|
+
|
|
|
+ # Add a second bottom relation
|
|
|
+ conformance_add("users/user/test/a", "formalisms/Bottom")
|
|
|
+
|
|
|
+ # And remove the one without model, to make sure that it is not a wildcard!
|
|
|
+ conformance_delete("users/user/test/a", "formalisms/Bottom", "")
|
|
|
+
|
|
|
+ ts = model_types("users/user/test/a")
|
|
|
+ assert len(ts) == 2
|
|
|
+ while ts:
|
|
|
+ t = ts.pop()
|
|
|
+ assert t[0] in ["formalisms/SimpleClassDiagrams", "formalisms/Bottom"]
|
|
|
+ assert t[1] != None
|
|
|
+ assert t[2] == None
|
|
|
+
|
|
|
+ # Add again, but now remove the one with type mapping
|
|
|
+ conformance_add("users/user/test/a", "formalisms/Bottom")
|
|
|
+
|
|
|
+ # First try one that doesn't match...
|
|
|
+ conformance_delete("users/user/test/a", "formalisms/Bottom", "NOTHING")
|
|
|
+
|
|
|
+ ts = model_types("users/user/test/a")
|
|
|
+ assert len(ts) == 3
|
|
|
+ while ts:
|
|
|
+ t = ts.pop()
|
|
|
+ assert t[0] in ["formalisms/SimpleClassDiagrams", "formalisms/Bottom"]
|
|
|
+ assert t[2] == None
|
|
|
+
|
|
|
+ # Now try one with the actual name
|
|
|
+ actual_name = [i for i in model_types("users/user/test/a") if i[0] == "formalisms/Bottom" and i[1] != None][0]
|
|
|
+
|
|
|
+ assert len(model_types("users/user/test/a")) == 3
|
|
|
+ conformance_delete("users/user/test/a", "formalisms/SimpleClassDiagrams", actual_name)
|
|
|
+ # Nothing removed, because of wrong TM model
|
|
|
+ assert len(model_types("users/user/test/a")) == 3
|
|
|
+
|
|
|
+ # Now remove correct one
|
|
|
+ conformance_delete("users/user/test/a", "formalisms/Bottom", actual_name)
|
|
|
+ ts = model_types("users/user/test/a")
|
|
|
+ assert len(ts) == 2
|
|
|
+ while ts:
|
|
|
+ t = ts.pop()
|
|
|
+ assert t[0] in ["formalisms/SimpleClassDiagrams", "formalisms/Bottom"]
|
|
|
+ if t[0] == "formalisms/SimpleClassDiagrams":
|
|
|
+ assert t[1] != None
|
|
|
+ elif t[1] == "formalisms/Bottom":
|
|
|
+ # Type mapping is empty
|
|
|
+ assert t[1] == None
|
|
|
+ assert t[2] == None
|
|
|
+
|
|
|
+
|
|
|
+ # Check add of non-existing model
|
|
|
+ try:
|
|
|
+ conformance_add("users/user/test/b", "formalisms/Bottom")
|
|
|
+ self.fail()
|
|
|
+ except UnknownModel:
|
|
|
+ pass
|
|
|
+
|
|
|
+ # Check add of non-existing metamodel
|
|
|
+ model_add("users/user/test/b", "formalisms/SimpleClassDiagrams")
|
|
|
+ before = model_types("users/user/test/b")
|
|
|
+ try:
|
|
|
+ conformance_add("users/user/test/b", "formalisms/Bottom2")
|
|
|
+ self.fail()
|
|
|
+ except UnknownModel:
|
|
|
+ assert model_types("users/user/test/b") == before
|
|
|
"""
|
|
|
def test_op_model_render(self):
|
|
|
def test_op_transformation_between(self):
|
|
@@ -3092,7 +3230,6 @@ class TestModelverse(unittest.TestCase):
|
|
|
def test_op_transformation_execute_MANUAL(self):
|
|
|
def test_op_transformation_signature(self):
|
|
|
def test_op_process_signature(self):
|
|
|
- def test_op_conformance_delete(self):
|
|
|
"""
|
|
|
|
|
|
def test_modelling(self):
|