From 64ce8c0bb1a2db3fa1767a48f0c09b96be79e424 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 10 Apr 2017 16:39:46 +0200 Subject: [PATCH] Add test for whether an empty stack deserialises to proper size It must be padded with empty containers. The test currently fails, and we concluded that we won't fix it as part of this refactor. We'll refactor this later and put it on skip until then to indicate a todo. Contributes to issue CURA-3497. --- tests/Settings/TestGlobalStack.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/Settings/TestGlobalStack.py b/tests/Settings/TestGlobalStack.py index 6b0e97111c..98f7906bdd 100644 --- a/tests/Settings/TestGlobalStack.py +++ b/tests/Settings/TestGlobalStack.py @@ -287,6 +287,21 @@ def test_constrainVariantInvalid(container, global_stack): def test_constrainDefinitionValid(container, global_stack): global_stack.definition = container #Should not give an error. +## Tests whether deserialising completes the missing containers with empty +# ones. +@pytest.mark.skip #The test currently fails because the definition container doesn't have a category, which is wrong but we don't have time to refactor that right now. +def test_deserializeCompletesEmptyContainers(global_stack: cura.Settings.GlobalStack): + global_stack._containers = [DefinitionContainer(container_id = "definition")] #Set the internal state of this stack manually. + + with unittest.mock.patch("UM.Settings.ContainerStack.ContainerStack.deserialize", unittest.mock.MagicMock()): #Prevent calling super().deserialize. + global_stack.deserialize("") + + assert len(global_stack.getContainers()) == len(cura.Settings.CuraContainerStack._ContainerIndexes.IndexTypeMap) #Needs a slot for every type. + for container_type_index in cura.Settings.CuraContainerStack._ContainerIndexes.IndexTypeMap: + if container_type_index == cura.Settings.CuraContainerStack._ContainerIndexes.Definition: #We're not checking the definition. + continue + assert global_stack.getContainer(container_type_index).getId() == "empty" #All others need to be empty. + ## Tests whether the user changes are being read properly from a global stack. @pytest.mark.parametrize("filename, user_changes_id", [ ("Global.global.cfg", "empty"),