From 5e9695773aad92911c16a00950cf593a94b1fa2c Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 10 Apr 2017 16:45:42 +0200 Subject: [PATCH] Add test for instance containers on definition spot When deserialize finds an instance container in the definition spot and no other container to replace it with, it should raise an exception because stacks must have a definition. Contributes to issue CURA-3497. --- tests/Settings/TestGlobalStack.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/Settings/TestGlobalStack.py b/tests/Settings/TestGlobalStack.py index 9665567698..38ecb8967a 100644 --- a/tests/Settings/TestGlobalStack.py +++ b/tests/Settings/TestGlobalStack.py @@ -324,6 +324,13 @@ def test_deserializeRemovesWrongContainerClass(global_stack): assert global_stack.quality == global_stack._empty_instance_container #Replaced with empty. +def test_deserializeWrongDefinitionClass(global_stack): + global_stack._containers[cura.Settings.CuraContainerStack._ContainerIndexes.Definition] = getInstanceContainer(container_type = "definition") #Correct type but wrong class. + + with unittest.mock.patch("UM.Settings.ContainerStack.ContainerStack.deserialize", unittest.mock.MagicMock()): #Prevent calling super().deserialize. + with pytest.raises(UM.Settings.ContainerStack.InvalidContainerStackError): #Must raise an error that there is no definition container. + global_stack.deserialize("") + ## Tests whether the user changes are being read properly from a global stack. @pytest.mark.skip @pytest.mark.parametrize("filename, user_changes_id", [