Browse Source

Update all local functions in unit tests to global functions for Windows

Yentl Van Tendeloo 3 years ago
parent
commit
1a0cf2f41f
1 changed files with 26 additions and 22 deletions
  1. 26 22
      unit/test_all.py

+ 26 - 22
unit/test_all.py

@@ -13,6 +13,18 @@ from modelverse import *
 
 import threading
 
+### Model operations
+def null_operation(model):
+    pass
+
+def model_is_empty_operation(model):
+    assert model is None
+
+def operation_exec_1(model):
+    assert model is not None
+    assert [{"__id": "MODEL_A/__0", "__type": "MODEL_A/A", "name": None}] == element_list_nice(model)
+    instantiate(model, "MODEL_B/B")
+
 model_hierarchy = \
             {"formalisms/": {"SimpleClassDiagrams": {},
                              "TypeMapping": {},
@@ -4485,21 +4497,13 @@ class TestModelverse(unittest.TestCase):
         # Add some activity to execute
         transformation_add_MANUAL({}, {}, "users/user/test/c")
 
-        def operation(model):
-            assert model is None
-
         # Now execute
-        transformation_execute_MANUAL("users/user/test/c", {}, {}, operation)
+        transformation_execute_MANUAL("users/user/test/c", {}, {}, model_is_empty_operation)
 
         # Now do the same, but with a model
         transformation_add_MANUAL({"MODEL_A": "users/user/test/A"}, {"MODEL_B": "users/user/test/B"}, "users/user/test/d")
 
-        def operation(model):
-            assert model is not None
-            assert [{"__id": "MODEL_A/__0", "__type": "MODEL_A/A", "name": None}] == element_list_nice(model)
-            instantiate(model, "MODEL_B/B")
-
-        transformation_execute_MANUAL("users/user/test/d", {"MODEL_A": "users/user/test/a"}, {"MODEL_B": "users/user/test/aa"}, operation)
+        transformation_execute_MANUAL("users/user/test/d", {"MODEL_A": "users/user/test/a"}, {"MODEL_B": "users/user/test/aa"}, operation_exec_1)
         lst = element_list_nice("users/user/test/aa")
         assert len(lst) == 1
         assert lst[0]["__type"] == "B"
@@ -4508,70 +4512,70 @@ class TestModelverse(unittest.TestCase):
 
         # Execute activity with non-existing model (input)
         try:
-            transformation_execute_MANUAL("users/user/test/d", {"MODEL_A": "dfadf"}, {"MODEL_B": "users/user/test/f"}, lambda i: i)
+            transformation_execute_MANUAL("users/user/test/d", {"MODEL_A": "dfadf"}, {"MODEL_B": "users/user/test/f"}, null_operation)
             self.fail()
         except UnknownModel:
             assert "f" not in model_list("users/user/test")
 
         # Execute non-existing activity
         try:
-            transformation_execute_MANUAL("adfadf", {}, {"MODEL_B": "users/user/test/abc"}, lambda i: i)
+            transformation_execute_MANUAL("adfadf", {}, {"MODEL_B": "users/user/test/abc"}, null_operation)
             self.fail()
         except UnknownModel:
             assert "abc" not in model_list("users/user/test")
 
         # Unbound source model
         try:
-            transformation_execute_MANUAL("users/user/test/d", {}, {"MODEL_B": "users/user/test/f"}, lambda i: i)
+            transformation_execute_MANUAL("users/user/test/d", {}, {"MODEL_B": "users/user/test/f"}, null_operation)
             self.fail()
         except SourceModelNotBound:
             pass
 
         # Unknown source key
         try:
-            transformation_execute_MANUAL("users/user/test/d", {"ABC": "users/user/test/a", "MODEL_A": "users/user/test/a"}, {"MODEL_B": "users/user/test/f"}, lambda i: i)
+            transformation_execute_MANUAL("users/user/test/d", {"ABC": "users/user/test/a", "MODEL_A": "users/user/test/a"}, {"MODEL_B": "users/user/test/f"}, null_operation)
             self.fail()
         except SourceModelNotBound:
             pass
 
         # Unknown target key
         try:
-            transformation_execute_MANUAL("users/user/test/d", {"MODEL_A": "users/user/test/a"}, {"DEF": "users/user/test/b"}, lambda i: i)
+            transformation_execute_MANUAL("users/user/test/d", {"MODEL_A": "users/user/test/a"}, {"DEF": "users/user/test/b"}, null_operation)
             self.fail()
         except TargetModelNotBound:
             pass
 
         # Read permissions denied source
         try:
-            transformation_execute_MANUAL("users/user/test/d", {"MODEL_A": "administration/core"}, {"MODEL_B": "users/user/test/f"}, lambda i: i)
+            transformation_execute_MANUAL("users/user/test/d", {"MODEL_A": "administration/core"}, {"MODEL_B": "users/user/test/f"}, null_operation)
             self.fail()
         except ReadPermissionDenied:
             pass
 
         # Execute permissions denied activity
         try:
-            transformation_execute_MANUAL("administration/core", {"MODEL_A": "users/user/test/a"}, {"MODEL_B": "users/user/test/f"}, lambda i: i)
+            transformation_execute_MANUAL("administration/core", {"MODEL_A": "users/user/test/a"}, {"MODEL_B": "users/user/test/f"}, null_operation)
             self.fail()
         except ExecutePermissionDenied:
             pass
 
         # Write permissions denied target (folder)
         try:
-            transformation_execute_MANUAL("users/user/test/d", {"MODEL_A": "users/user/test/a"}, {"MODEL_B": "administration/abc"}, lambda i: i)
+            transformation_execute_MANUAL("users/user/test/d", {"MODEL_A": "users/user/test/a"}, {"MODEL_B": "administration/abc"}, null_operation)
             self.fail()
         except WritePermissionDenied:
             pass
 
         # Write permissions denied target (model)
         try:
-            transformation_execute_MANUAL("users/user/test/d", {"MODEL_A": "users/user/test/a"}, {"MODEL_B": "administration/core"}, lambda i: i)
+            transformation_execute_MANUAL("users/user/test/d", {"MODEL_A": "users/user/test/a"}, {"MODEL_B": "administration/core"}, null_operation)
             self.fail()
         except WritePermissionDenied:
             pass
 
         # Execute activity with non-conforming input models
         try:
-            transformation_execute_MANUAL("users/user/test/d", {"MODEL_A": "users/user/test/b"}, {"MODEL_B": "users/user/test/f"}, lambda i: i)
+            transformation_execute_MANUAL("users/user/test/d", {"MODEL_A": "users/user/test/b"}, {"MODEL_B": "users/user/test/f"}, null_operation)
             self.fail()
         except TypeMismatch:
             assert "f" not in model_list("users/user/test")
@@ -4579,7 +4583,7 @@ class TestModelverse(unittest.TestCase):
         # Execute activity with non-conforming output models that already exist
         assert len(element_list_nice("users/user/test/aa")) > 0
         try:
-            transformation_execute_MANUAL("users/user/test/d", {"MODEL_A": "users/user/test/b"}, {"MODEL_B": "users/user/test/aa"}, lambda i: i)
+            transformation_execute_MANUAL("users/user/test/d", {"MODEL_A": "users/user/test/b"}, {"MODEL_B": "users/user/test/aa"}, null_operation)
             self.fail()
         except TypeMismatch:
             assert len(element_list_nice("users/user/test/aa")) > 0
@@ -4600,7 +4604,7 @@ class TestModelverse(unittest.TestCase):
 
         # Execute activity with colliding models, which means that it is copied
         transformation_add_MANUAL({"MODEL_A": "users/user/test/A"}, {"MODEL_A": "users/user/test/A"}, "users/user/test/f")
-        transformation_execute_MANUAL("users/user/test/f", {"MODEL_A": "users/user/test/a"}, {"MODEL_A": "users/user/test/aaa"}, lambda i: i)
+        transformation_execute_MANUAL("users/user/test/f", {"MODEL_A": "users/user/test/a"}, {"MODEL_A": "users/user/test/aaa"}, null_operation)
         assert len(element_list_nice("users/user/test/a")) == len(element_list_nice("users/user/test/aaa"))
 
     def test_op_transformation_execute_AL(self):