diff --git a/tests/Settings/TestGlobalStack.py b/tests/Settings/TestGlobalStack.py index 83b5226109..d2f2bc881e 100644 --- a/tests/Settings/TestGlobalStack.py +++ b/tests/Settings/TestGlobalStack.py @@ -6,7 +6,7 @@ import pytest #This module contains unit tests. import unittest.mock #To monkeypatch some mocks in place of dependencies. import cura.Settings.GlobalStack #The module we're testing. -from cura.Settings.Exceptions import TooManyExtrudersError #To test raising this error. +from cura.Settings.Exceptions import TooManyExtrudersError, InvalidOperationError #To test raising these errors. from UM.Settings.DefinitionContainer import DefinitionContainer #To test against the class DefinitionContainer. import UM.Settings.ContainerRegistry import UM.Settings.ContainerStack @@ -50,6 +50,11 @@ def readStack(filename): #############################START OF TEST CASES################################ +## Tests whether adding a container is properly forbidden. +def test_addContainer(global_stack): + with pytest.raises(InvalidOperationError): + global_stack.addContainer(unittest.mock.MagicMock()) + ## Tests adding extruders to the global stack. def test_addExtruder(global_stack): mock_definition = unittest.mock.MagicMock() @@ -301,4 +306,18 @@ def test_hasUserValueQualityChanges(global_stack): assert not global_stack.hasUserValue("infill_sparse_density") assert global_stack.hasUserValue("layer_height") - assert not global_stack.hasUserValue("") \ No newline at end of file + assert not global_stack.hasUserValue("") + +## Tests whether inserting a container is properly forbidden. +def test_insertContainer(global_stack): + with pytest.raises(InvalidOperationError): + global_stack.insertContainer(0, unittest.mock.MagicMock()) + +def test_removeContainer(global_stack): + with pytest.raises(InvalidOperationError): + global_stack.removeContainer(unittest.mock.MagicMock()) + +## Tests whether changing the next stack is properly forbidden. +def test_setNextStack(global_stack): + with pytest.raises(InvalidOperationError): + global_stack.setNextStack(unittest.mock.MagicMock()) \ No newline at end of file