Browse Source

Test for process_execute; and a patch for a bug related to folders

Yentl Van Tendeloo 7 years ago
parent
commit
32ad5387c8
2 changed files with 47 additions and 11 deletions
  1. 16 8
      bootstrap/core_algorithm.alc
  2. 31 3
      unit/test_all.py

+ 16 - 8
bootstrap/core_algorithm.alc

@@ -1136,16 +1136,24 @@ String function cmd_process_execute(process : String, mapping : Element):
 
 	process_id = get_entry_id(process)
 	if (process_id != ""):
-		if (allow_execute(current_user_id, process_id)):
-			Element pm
-			pm = get_full_model(process_id, get_entry_id("formalisms/ProcessModel"))
-			if (element_eq(pm, read_root())):
-				return "Specified model cannot be interpreted as a ProcessModel: " + process!
+		if (read_type(core, process) != "Folder"):
+			if (allow_execute(current_user_id, process_id)):
+				Element pm
+				pm = get_full_model(process_id, get_entry_id("formalisms/ProcessModel"))
+				if (element_eq(pm, read_root())):
+					return "Not a ProcessModel: " + process!
 
-			enact_PM(pm, mapping)
-			return "Success"!
+				String ver
+				ver = conformance_scd(pm)
+				if (ver == "OK"):
+					enact_PM(pm, mapping)
+					return "Success"!
+				else:
+					return "Not a valid ProcessModel: " + ver!
+			else:
+				return "Execute permission denied to: " + process!
 		else:
-			return "Execute permission denied to: " + process!
+			return "Not a model: " + process!
 	else:
 		return "Model not found: " + process!
 

+ 31 - 3
unit/test_all.py

@@ -5237,10 +5237,38 @@ class TestModelverse(unittest.TestCase):
         except ExecutePermissionDenied:
             pass
 
-    """
-    def test_op_model_render(self):
     def test_op_process_execute(self):
-    """
+        # This is only a minimal test, as actual execution will take a long time.
+        # For example, the integration tests rely solely on the process_execute operation, thereby being a good test for this.
+        # We now just test the execution in corner cases
+
+        # Test with non-existing model
+        try:
+            process_execute("abc", {})
+            self.fail()
+        except UnknownModel:
+            pass
+
+        # Test with folder model
+        try:
+            process_execute("formalisms", {})
+            self.fail()
+        except NotAModel:
+            pass
+
+        # Test with unreadable model
+        try:
+            process_execute("administration/core", {})
+            self.fail()
+        except ExecutePermissionDenied:
+            pass
+
+        # Test with non-process model
+        try:
+            process_execute("formalisms/SimpleClassDiagrams", {})
+            self.fail()
+        except NotAProcess:
+            pass
 
     def test_modelling(self):
         # Add a model