|
@@ -1,10 +1,24 @@
|
|
|
# Copyright (c) 2018 Ultimaker B.V.
|
|
|
# Cura is released under the terms of the LGPLv3 or higher.
|
|
|
|
|
|
+from unittest import mock
|
|
|
+
|
|
|
import pytest
|
|
|
|
|
|
from cura.MachineAction import MachineAction
|
|
|
from cura.MachineActionManager import NotUniqueMachineActionError, UnknownMachineActionError
|
|
|
+from cura.Settings.GlobalStack import GlobalStack
|
|
|
+
|
|
|
+
|
|
|
+@pytest.fixture()
|
|
|
+def global_stack():
|
|
|
+ gs = GlobalStack("test_global_stack")
|
|
|
+ gs._metadata = {"supported_actions": ["supported_action_1", "supported_action_2"],
|
|
|
+ "required_actions": ["required_action_1", "required_action_2"],
|
|
|
+ "first_start_actions": ["first_start_actions_1", "first_start_actions_2"]
|
|
|
+ }
|
|
|
+ return gs
|
|
|
+
|
|
|
|
|
|
class Machine:
|
|
|
def __init__(self, key = ""):
|
|
@@ -13,6 +27,28 @@ class Machine:
|
|
|
def getKey(self):
|
|
|
return self._key
|
|
|
|
|
|
+
|
|
|
+def test_addDefaultMachineActions(machine_action_manager, global_stack):
|
|
|
+ all_actions = []
|
|
|
+ for action_key_list in global_stack._metadata.values():
|
|
|
+ for key in action_key_list:
|
|
|
+ all_actions.append(MachineAction(key = key))
|
|
|
+ for action in all_actions:
|
|
|
+ machine_action_manager.addMachineAction(action)
|
|
|
+
|
|
|
+ machine_action_manager.addDefaultMachineActions(global_stack)
|
|
|
+ definition_id = global_stack.getDefinition().getId()
|
|
|
+
|
|
|
+ support_action_keys = [a.getKey() for a in machine_action_manager.getSupportedActions(definition_id)]
|
|
|
+ assert support_action_keys == global_stack.getMetaDataEntry("supported_actions")
|
|
|
+
|
|
|
+ required_action_keys = [a.getKey() for a in machine_action_manager.getRequiredActions(definition_id)]
|
|
|
+ assert required_action_keys == global_stack.getMetaDataEntry("required_actions")
|
|
|
+
|
|
|
+ first_start_action_keys = [a.getKey() for a in machine_action_manager.getFirstStartActions(definition_id)]
|
|
|
+ assert first_start_action_keys == global_stack.getMetaDataEntry("first_start_actions")
|
|
|
+
|
|
|
+
|
|
|
def test_addMachineAction(machine_action_manager):
|
|
|
|
|
|
test_action = MachineAction(key = "test_action")
|