Browse Source

Add corner case tests

Yentl Van Tendeloo 7 years ago
parent
commit
391a8aedac
1 changed files with 48 additions and 0 deletions
  1. 48 0
      unit/test_all.py

+ 48 - 0
unit/test_all.py

@@ -1267,6 +1267,54 @@ class TestModelverse(unittest.TestCase):
             """.strip()
         assert AL_text(attrs["constraint"]["AL"]).strip () != old_text.strip()
 
+        simple_code = \
+            """
+                String function a(value : Element):
+                    return "OK"!
+            """
+
+        # Non-existing model
+        try:
+            attr_assign_code("users/afa", "p1", "name", simple_code)
+            self.fail()
+        except UnknownModel:
+            pass
+
+        # Non-existing element
+        try:
+            attr_assign_code("users/user/test/a", "PPPPPPP", "name", simple_code)
+            self.fail()
+        except UnknownElement:
+            pass
+
+        # No read permissions
+        try:
+            attr_assign_code("administration/core", "formalisms", "name", simple_code)
+            self.fail()
+        except ReadPermissionDenied:
+            pass
+
+        # No write permissions
+        try:
+            attr_assign_code("formalisms/SimpleClassDiagrams", "Class", "name", simple_code)
+            self.fail()
+        except WritePermissionDenied:
+            pass
+
+        # No such attribute
+        try:
+            attr_assign_code("users/user/test/a", "Place", "ddd", simple_code)
+            self.fail()
+        except UnknownAttribute:
+            pass
+
+        # Compilation error
+        try:
+            attr_assign_code("users/user/test/a", "Place", "constraint", "abc")
+            self.fail()
+        except CompilationError:
+            pass
+
     """
     def test_op_model_render(self):
     def test_op_transformation_between(self):