浏览代码

Added test for all_instances (parts hang MV)

Yentl Van Tendeloo 7 年之前
父节点
当前提交
849ee0dc70
共有 1 个文件被更改,包括 31 次插入2 次删除
  1. 31 2
      unit/test_all.py

+ 31 - 2
unit/test_all.py

@@ -427,9 +427,39 @@ class TestModelverse(unittest.TestCase):
             self.fail()
         except ReadPermissionDenied:
             pass
+    
+    def test_op_all_instances(self):
+        model_add("users/user/test/a", "formalisms/SimpleClassDiagrams", """
+            Class A {}
+            Class B : A {}
+            Association C (A, B) {}
+            """)
+        assert all_instances("users/user/test/a", "Class") == set(["A", "B"])
+        assert all_instances("users/user/test/a", "Association") == set(["C"])
+
+        try:
+            all_instances("users/user/test/a", "non-existing")
+            self.fail()
+        except UnknownElement:
+            pass
+
+        #try:
+        #    all_instances("users/user/test/b", "Class")
+        #    self.fail()
+        #except UnknownLocation:
+        #    pass
+
+        model_add("users/user/test/b", "users/user/test/a", """
+            A a {}
+            B b {}
+            C c(a, b) {}
+            A d {}
+            """)
+        assert all_instances("users/user/test/b", "A") == set(["a", "b", "d"])
+        assert all_instances("users/user/test/b", "B") == set(["b"])
+        assert all_instances("users/user/test/b", "C") == set(["c"])
 
     """
-    def test_op_user_delete(self):
     def test_op_model_render(self):
     def test_op_transformation_between(self):
     def test_op_transformation_add_MT(self):
@@ -475,7 +505,6 @@ class TestModelverse(unittest.TestCase):
     def test_op_read_association_destination(self):
     def test_op_conections_between(self):
     def test_op_define_attribute(self):
-    def test_op_all_instances(self):
     """
 
     def test_modelling(self):