浏览代码

Patches for model_modify again

Yentl Van Tendeloo 7 年之前
父节点
当前提交
7585239c22
共有 4 个文件被更改,包括 29 次插入29 次删除
  1. 0 19
      bootstrap/mini_modify.alc
  2. 28 1
      unit/test_all.py
  3. 1 5
      wrappers/classes/modelverse.xml
  4. 0 4
      wrappers/modelverse_SCCD.py

+ 0 - 19
bootstrap/mini_modify.alc

@@ -266,23 +266,6 @@ String function cmd_delete(write : Boolean, model : Element, element_name : Stri
 	else:
 		return "Write permission denied"!
 
-String function cmd_list(model : Element):
-	Element keys_m
-	String v_m
-	String result
-	String typename
-
-	result = "Success: "
-	keys_m = dict_keys(model["model"])
-	while (set_len(keys_m) > 0):
-		v_m = set_pop(keys_m)
-		// Filter out anonymous objects
-		if (bool_not(string_startswith(v_m, "__"))):
-			typename = read_type(model, v_m)
-			result = result + "  " + v_m + " : " + typename + "\n"
-	
-	return result!
-
 String function cmd_list_full(model : Element):
 	Element keys_m
 	String v_m
@@ -493,8 +476,6 @@ Boolean function modify(model : Element, write : Boolean):
 			output(cmd_attr_optional(write, model, single_input("Name?"), single_input("Attribute name?"), input()))
 		elif (cmd == "delete"):
 			output(cmd_delete(write, model, single_input("Name?")))
-		elif (cmd == "list"):
-			output(cmd_list(model))
 		elif (cmd == "list_full"):
 			output(cmd_list_full(model))
 		elif (cmd == "JSON"):

+ 28 - 1
unit/test_all.py

@@ -634,6 +634,34 @@ class TestModelverse(unittest.TestCase):
         # as such, errors are not noticed until the element is accessed!
         alter_context("non-existing", "formalisms/SimpleClassDiagrams")
 
+    def test_op_element_list(self):
+        model_add("users/user/test/a", "formalisms/ProcessModel", """
+            Start start {}
+            Finish finish {}
+            Next nxt (start, finish) {}
+            """)
+
+        # Basic operation
+        lst = element_list("users/user/test/a")
+        assert len(lst) == 3
+        assert ("start", "Start") in lst
+        assert ("finish", "Finish") in lst
+        assert ("nxt", "Next") in lst
+
+        # Try on non-existing model
+        try:
+            element_list("a")
+            self.fail()
+        except UnknownModel:
+            pass
+
+        # Try a non-readable model
+        try:
+            element_list("administration/core")
+            self.fail()
+        except ReadPermissionDenied:
+            pass
+
     """
     def test_op_model_render(self):
     def test_op_transformation_between(self):
@@ -656,7 +684,6 @@ class TestModelverse(unittest.TestCase):
     def test_op_group_list(self):
     def test_op_conformance_delete(self):
     def test_op_conformance_add(self):
-    def test_op_element_list(self):
     def test_op_element_list_nice(self):
     def test_op_types(self):
     def test_op_types_full(self):

+ 1 - 5
wrappers/classes/modelverse.xml

@@ -1822,11 +1822,7 @@
                             <state id="manual">
                                 <transition cond="self.expect_action('exit')" target="../../../../leaving_manual"/>
 
-                                <transition cond="self.actions and self.actions[0]['name'] in self.modelling_operations and self.actions[0]['parameters'][0] != self.current_model" target="../../../../leaving_manual">
-                                    <script>
-                                        print("Switching to normal for model " + str(self.actions[0]))
-                                    </script>
-                                </transition>
+                                <transition cond="self.actions and self.actions[0]['name'] in self.modelling_operations and self.actions[0]['parameters'][0] != self.current_model" target="../../../../leaving_manual"/>
                             </state>
 
                             <state id="scripted">

+ 0 - 4
wrappers/modelverse_SCCD.py

@@ -1609,7 +1609,6 @@ class Modelverse(RuntimeClassBase):
         _initialized_behaviour_wait_for_action_modelling_recognized_manual_0.setGuard(self._initialized_behaviour_wait_for_action_modelling_recognized_manual_0_guard)
         self.states["/initialized/behaviour/wait_for_action/modelling/recognized/manual"].addTransition(_initialized_behaviour_wait_for_action_modelling_recognized_manual_0)
         _initialized_behaviour_wait_for_action_modelling_recognized_manual_1 = Transition(self, self.states["/initialized/behaviour/wait_for_action/modelling/recognized/manual"], [self.states["/initialized/behaviour/leaving_manual"]])
-        _initialized_behaviour_wait_for_action_modelling_recognized_manual_1.setAction(self._initialized_behaviour_wait_for_action_modelling_recognized_manual_1_exec)
         _initialized_behaviour_wait_for_action_modelling_recognized_manual_1.setTrigger(None)
         _initialized_behaviour_wait_for_action_modelling_recognized_manual_1.setGuard(self._initialized_behaviour_wait_for_action_modelling_recognized_manual_1_guard)
         self.states["/initialized/behaviour/wait_for_action/modelling/recognized/manual"].addTransition(_initialized_behaviour_wait_for_action_modelling_recognized_manual_1)
@@ -3374,9 +3373,6 @@ class Modelverse(RuntimeClassBase):
     def _initialized_behaviour_wait_for_action_modelling_recognized_manual_0_guard(self, parameters):
         return self.expect_action('exit')
     
-    def _initialized_behaviour_wait_for_action_modelling_recognized_manual_1_exec(self, parameters):
-        print("Switching to normal for model " + str(self.actions[0]))
-    
     def _initialized_behaviour_wait_for_action_modelling_recognized_manual_1_guard(self, parameters):
         return self.actions and self.actions[0]['name'] in self.modelling_operations and self.actions[0]['parameters'][0] != self.current_model