|
@@ -1315,6 +1315,117 @@ class TestModelverse(unittest.TestCase):
|
|
|
except CompilationError:
|
|
|
pass
|
|
|
|
|
|
+ def test_op_instantiate(self):
|
|
|
+ model_add("users/user/test/a", "formalisms/SimpleClassDiagrams")
|
|
|
+ assert element_list("users/user/test/a") == set([])
|
|
|
+
|
|
|
+ # Instantiate node element
|
|
|
+ ID = instantiate("users/user/test/a", "Class")
|
|
|
+ assert element_list("users/user/test/a") == set([(ID, "Class")])
|
|
|
+ assert read_info("users/user/test/a", ID) == ("Class", None)
|
|
|
+
|
|
|
+ # Instantiate node element with ID
|
|
|
+ ID2 = instantiate("users/user/test/a", "Class", ID="new_node")
|
|
|
+ assert ID2 == "new_node"
|
|
|
+ assert element_list("users/user/test/a") == set([(ID, "Class"), (ID2, "Class")])
|
|
|
+ assert read_info("users/user/test/a", ID2) == ("Class", None)
|
|
|
+
|
|
|
+ # Instantiate edge element
|
|
|
+ ID3 = instantiate("users/user/test/a", "Association", edge=(ID, ID2))
|
|
|
+ assert element_list("users/user/test/a") == set([(ID, "Class"), (ID2, "Class"), (ID3, "Association")])
|
|
|
+ assert read_info("users/user/test/a", ID3) == ("Association", (ID, ID2))
|
|
|
+
|
|
|
+ # Instantiate edge element with ID
|
|
|
+ ID4 = instantiate("users/user/test/a", "Association", edge=(ID, ID2), ID="new_edge")
|
|
|
+ assert ID4 == "new_edge"
|
|
|
+ assert element_list("users/user/test/a") == set([(ID, "Class"), (ID2, "Class"), (ID3, "Association"), (ID4, "Association")])
|
|
|
+ assert read_info("users/user/test/a", ID4) == ("Association", (ID, ID2))
|
|
|
+
|
|
|
+ # Instantiate edge from edge (source)
|
|
|
+ ID5 = instantiate("users/user/test/a", "Association", edge=(ID3, ID))
|
|
|
+ assert element_list("users/user/test/a") == set([(ID, "Class"), (ID2, "Class"), (ID3, "Association"), (ID4, "Association"), (ID5, "Association")])
|
|
|
+ assert read_info("users/user/test/a", ID5) == ("Association", (ID3, ID))
|
|
|
+
|
|
|
+ # Instantiate edge from edge (target)
|
|
|
+ ID6 = instantiate("users/user/test/a", "Association", edge=(ID, ID3))
|
|
|
+ assert element_list("users/user/test/a") == set([(ID, "Class"), (ID2, "Class"), (ID3, "Association"), (ID4, "Association"), (ID5, "Association"), (ID6, "Association")])
|
|
|
+ assert read_info("users/user/test/a", ID6) == ("Association", (ID, ID3))
|
|
|
+
|
|
|
+ # Instantiate edge from edge (source and target)
|
|
|
+ ID7 = instantiate("users/user/test/a", "Association", edge=(ID3, ID4))
|
|
|
+ assert element_list("users/user/test/a") == set([(ID, "Class"), (ID2, "Class"), (ID3, "Association"), (ID4, "Association"), (ID5, "Association"), (ID6, "Association"), (ID7, "Association")])
|
|
|
+ assert read_info("users/user/test/a", ID7) == ("Association", (ID3, ID4))
|
|
|
+
|
|
|
+ # Non-existing model
|
|
|
+ try:
|
|
|
+ instantiate("users/afa", "Association")
|
|
|
+ self.fail()
|
|
|
+ except UnknownModel:
|
|
|
+ pass
|
|
|
+
|
|
|
+ # Non-existing element
|
|
|
+ before = element_list("users/user/test/a")
|
|
|
+ try:
|
|
|
+ instantiate("users/user/test/a", "AAAAAAA")
|
|
|
+ self.fail()
|
|
|
+ except UnknownElement:
|
|
|
+ assert element_list("users/user/test/a") == before
|
|
|
+
|
|
|
+ # No read permissions
|
|
|
+ try:
|
|
|
+ instantiate("administration/core", "formalisms")
|
|
|
+ self.fail()
|
|
|
+ except ReadPermissionDenied:
|
|
|
+ pass
|
|
|
+
|
|
|
+ # No write permissions
|
|
|
+ before = element_list("users/user/test/a")
|
|
|
+ try:
|
|
|
+ instantiate("formalisms/SimpleClassDiagrams", "Class")
|
|
|
+ self.fail()
|
|
|
+ except WritePermissionDenied:
|
|
|
+ assert element_list("users/user/test/a") == before
|
|
|
+
|
|
|
+ # Pre-existing ID requested (node)
|
|
|
+ before = element_list("users/user/test/a")
|
|
|
+ try:
|
|
|
+ instantiate("users/user/test/a", "Class", ID=ID)
|
|
|
+ self.fail()
|
|
|
+ except ElementExists:
|
|
|
+ assert element_list("users/user/test/a") == before
|
|
|
+
|
|
|
+ # Pre-existing ID requested (edge)
|
|
|
+ before = element_list("users/user/test/a")
|
|
|
+ try:
|
|
|
+ instantiate("users/user/test/a", "Association", ID=ID, edge=(ID2, ID3))
|
|
|
+ self.fail()
|
|
|
+ except ElementExists:
|
|
|
+ assert element_list("users/user/test/a") == before
|
|
|
+
|
|
|
+ # Edge from non-existing ID
|
|
|
+ before = element_list("users/user/test/a")
|
|
|
+ try:
|
|
|
+ instantiate("users/user/test/a", "Association", ID=ID, edge=("non-existing", ID3))
|
|
|
+ self.fail()
|
|
|
+ except ElementExists:
|
|
|
+ assert element_list("users/user/test/a") == before
|
|
|
+
|
|
|
+ # Edge to non-existing ID
|
|
|
+ before = element_list("users/user/test/a")
|
|
|
+ try:
|
|
|
+ instantiate("users/user/test/a", "Association", ID=ID, edge=("non-existing", ID3))
|
|
|
+ self.fail()
|
|
|
+ except ElementExists:
|
|
|
+ assert element_list("users/user/test/a") == before
|
|
|
+
|
|
|
+ # Edge both non-existing ID
|
|
|
+ before = element_list("users/user/test/a")
|
|
|
+ try:
|
|
|
+ instantiate("users/user/test/a", "Association", ID=ID, edge=("non-existing", "non-existing2"))
|
|
|
+ self.fail()
|
|
|
+ except ElementExists:
|
|
|
+ assert element_list("users/user/test/a") == before
|
|
|
+
|
|
|
"""
|
|
|
def test_op_model_render(self):
|
|
|
def test_op_transformation_between(self):
|
|
@@ -1337,7 +1448,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_instantiate(self):
|
|
|
def test_op_delete_element(self):
|
|
|
def test_op_AL_text(self):
|
|
|
def test_op_read_outgoing(self):
|