Browse Source

Add test for read_association_destination

Yentl Van Tendeloo 7 years ago
parent
commit
83603a8892
1 changed files with 51 additions and 0 deletions
  1. 51 0
      unit/test_all.py

+ 51 - 0
unit/test_all.py

@@ -1763,6 +1763,57 @@ class TestModelverse(unittest.TestCase):
         # No write permissions, but can query
         assert read_association_source("formalisms/SimpleClassDiagrams", "Association") == "Class"
 
+    def test_op_read_association_destination(self):
+        model_add("users/user/test/a", "formalisms/SimpleClassDiagrams", """
+            SimpleAttribute String {}
+            Class A {
+                name : String
+            }
+            Class B {}
+            Association C (A, B) {}
+            Association E (A, A) {}
+            Association D (C, B) {}
+            Association F (D, E) {}
+            """)
+
+        # Test normal operation
+        assert read_association_destination("users/user/test/a", "C") == "B"
+
+        # Test association on association
+        assert read_association_destination("users/user/test/a", "F") == "E"
+
+        # Test node
+        try:
+            assert read_association_destination("users/user/test/a", "A")
+            self.fail()
+        except NotAnAssociation:
+            pass
+
+        # Non-existing model
+        try:
+            read_association_destination("users/afa", "Association")
+            self.fail()
+        except UnknownModel:
+            pass
+
+        # Non-existing element
+        before = element_list("users/user/test/a")
+        try:
+            read_association_destination("users/user/test/a", "AAAAAAA")
+            self.fail()
+        except UnknownElement:
+            assert element_list("users/user/test/a") == before
+
+        # No read permissions
+        try:
+            read_association_destination("administration/core", "formalisms")
+            self.fail()
+        except ReadPermissionDenied:
+            pass
+
+        # No write permissions, but can query
+        assert read_association_destination("formalisms/SimpleClassDiagrams", "Association") == "Class"
+
     """
     def test_op_model_render(self):
     def test_op_transformation_between(self):