From bf2050479b396de5f4e886775b23eedec92b1dc0 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 23 Mar 2017 16:09:03 +0100 Subject: [PATCH] Add tests for hasUserValue These fail at the moment because they also depend on being able to change the stack, which isn't implemented yet. Contributes to issue CURA-3497. --- tests/Settings/TestGlobalStack.py | 32 ++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/Settings/TestGlobalStack.py b/tests/Settings/TestGlobalStack.py index f624fad329..9d55ae16b6 100644 --- a/tests/Settings/TestGlobalStack.py +++ b/tests/Settings/TestGlobalStack.py @@ -186,4 +186,34 @@ def test_deserializeDefinition(filename, definition_id, container_registry): stack.deserialize(serialized) - assert stack.definition.getId() == definition_id \ No newline at end of file + assert stack.definition.getId() == definition_id + +## Tests whether the hasUserValue returns true for settings that are changed in +# the user-changes container. +def test_hasUserValueUserChanges(): + user_changes = unittest.mock.MagicMock() + def hasProperty(key, property): + return key == "layer_height" and property == "value" #Only have the layer_height property set. + user_changes.hasProperty = hasProperty + + stack = cura.Settings.GlobalStack.GlobalStack("TestStack") + stack.userChanges = user_changes + + assert not stack.hasUserValue("infill_sparse_density") + assert stack.hasUserValue("layer_height") + assert not stack.hasUserValue("") + +## Tests whether the hasUserValue returns true for settings that are changed in +# the quality-changes container. +def test_hasUserValueQualityChanges(): + quality_changes = unittest.mock.MagicMock() + def hasProperty(key, property): + return key == "layer_height" and property == "value" #Only have the layer_height property set. + quality_changes.hasProperty = hasProperty + + stack = cura.Settings.GlobalStack.GlobalStack("TestStack") + stack.qualityChanges = quality_changes + + assert not stack.hasUserValue("infill_sparse_density") + assert stack.hasUserValue("layer_height") + assert not stack.hasUserValue("") \ No newline at end of file