diff options
author | Jaime van Kessel <nallath@gmail.com> | 2020-08-21 17:02:26 +0300 |
---|---|---|
committer | Jaime van Kessel <nallath@gmail.com> | 2020-08-21 17:02:26 +0300 |
commit | 1affc345b9f46596badc99f5f231b2f44dd94208 (patch) | |
tree | 9f004f12ea9919116d34d90912823e640747a31e | |
parent | 4a47606176ac7f52943ca1508e349b64d4a56d74 (diff) |
Add test for clearUserSettingAllCurrentStacks
-rw-r--r-- | tests/TestMachineManager.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/TestMachineManager.py b/tests/TestMachineManager.py index 35afa7c481..3e610684e4 100644 --- a/tests/TestMachineManager.py +++ b/tests/TestMachineManager.py @@ -192,3 +192,31 @@ def test_setInvalidActiveMachine(machine_manager): # Notification stuff should happen now! configuration_error_message.addFaultyContainers.assert_called_once_with("InvalidMachine") +def test_clearUserSettingsAllCurrentStacks(machine_manager, application): + global_stack = application.getGlobalContainerStack() + extruder_1 = createMockedExtruder("extruder_1") + instance_container = createMockedInstanceContainer("user", "UserContainer") + extruder_1.getTop = MagicMock(return_value = instance_container) + global_stack.extruderList = [extruder_1] + + machine_manager.clearUserSettingAllCurrentStacks("some_setting") + + instance_container.removeInstance.assert_called_once_with("some_setting", postpone_emit=True) + + +def test_clearUserSettingsAllCurrentStacksLinkedSetting(machine_manager, application): + global_stack = application.getGlobalContainerStack() + extruder_1 = createMockedExtruder("extruder_1") + instance_container = createMockedInstanceContainer("user", "UserContainer") + instance_container_global = createMockedInstanceContainer("global_user", "GlobalUserContainer") + global_stack.getTop = MagicMock(return_value = instance_container_global) + extruder_1.getTop = MagicMock(return_value=instance_container) + global_stack.extruderList = [extruder_1] + + global_stack.getProperty = MagicMock(side_effect = lambda key, prop: True if prop == "settable_per_extruder" else "-1" ) + + machine_manager.clearUserSettingAllCurrentStacks("some_setting") + + instance_container.removeInstance.assert_not_called() + instance_container_global.removeInstance.assert_called_once_with("some_setting", postpone_emit = True) + |