Переглянути джерело

Add tests for read_incoming

Yentl Van Tendeloo 7 роки тому
батько
коміт
33d01180ab
1 змінених файлів з 58 додано та 1 видалено
  1. 58 1
      unit/test_all.py

+ 58 - 1
unit/test_all.py

@@ -1615,7 +1615,6 @@ class TestModelverse(unittest.TestCase):
         except UnknownElement:
             assert element_list("users/user/test/a") == before
 
-
         # No read permissions
         try:
             read_outgoing("administration/core", "formalisms", "")
@@ -1623,6 +1622,64 @@ class TestModelverse(unittest.TestCase):
         except ReadPermissionDenied:
             pass
 
+    def test_op_read_incoming(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_incoming("users/user/test/a", "B", "Association") == set(["C", "D"])
+
+        # Test wildcard
+        assert read_incoming("users/user/test/a", "B", "") == set(["C", "D"])
+
+        # Test association on association
+        assert read_incoming("users/user/test/a", "E", "") == set(["F"])
+
+        # Test double result
+        assert read_incoming("users/user/test/a", "A", "") == set(["E"])
+
+        # Test simpleattribute
+        assert read_incoming("users/user/test/a", "String", "") == set(["A_name"])
+
+        # Non-existing model
+        try:
+            read_incoming("users/afa", "Association", "")
+            self.fail()
+        except UnknownModel:
+            pass
+
+        # Non-existing element
+        before = element_list("users/user/test/a")
+        try:
+            read_incoming("users/user/test/a", "AAAAAAA", "")
+            self.fail()
+        except UnknownElement:
+            assert element_list("users/user/test/a") == before
+
+        # Non-existing type
+        before = element_list("users/user/test/a")
+        try:
+            read_incoming("users/user/test/a", "A", "AAAAAAA")
+            self.fail()
+        except UnknownElement:
+            assert element_list("users/user/test/a") == before
+
+        # No read permissions
+        try:
+            read_incoming("administration/core", "formalisms", "")
+            self.fail()
+        except ReadPermissionDenied:
+            pass
+
     """
     def test_op_model_render(self):
     def test_op_transformation_between(self):