From 86b288cc6ebf62918aa994efbe229513fa2d84d0 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 11 Apr 2017 10:39:07 +0200 Subject: [PATCH] Add test for when instances have value and definition has resolve The value of the instances should always get evaluated first. 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 2233561c7a..b98459ce2f 100644 --- a/tests/Settings/TestGlobalStack.py +++ b/tests/Settings/TestGlobalStack.py @@ -448,6 +448,21 @@ def test_getPropertyResolveInInstance(global_stack): global_stack.userChanges = instance_containers[container_indices.UserChanges] assert global_stack.getProperty("material_bed_temperature", "value") == 5 +## Tests whether the value in instances gets evaluated before the resolve in +# definitions. +def test_getPropertyInstancesBeforeResolve(global_stack): + value = unittest.mock.MagicMock() #Sets just the value. + value.getProperty = lambda key, property: 10 if (key == "material_bed_temperature" and property == "value") else None + value.getMetaDataEntry = unittest.mock.MagicMock(return_value = "quality") + resolve = unittest.mock.MagicMock() #Sets just the resolve. + resolve.getProperty = lambda key, property: 7.5 if (key == "material_bed_temperature" and property == "resolve") else None + + with unittest.mock.patch("cura.Settings.CuraContainerStack.DefinitionContainer", unittest.mock.MagicMock): #To guard against the type checking. + global_stack.definition = resolve + global_stack.quality = value + + assert global_stack.getProperty("material_bed_temperature", "value") == 10 + ## Tests whether the resolve property is properly obtained in all cases. @pytest.mark.skip def test_getPropertyWithResolve(global_stack):