diff --git a/tests/Settings/TestGlobalStack.py b/tests/Settings/TestGlobalStack.py index 632baa4c05..7eb1cac064 100644 --- a/tests/Settings/TestGlobalStack.py +++ b/tests/Settings/TestGlobalStack.py @@ -280,6 +280,41 @@ def test_getPropertyFallThrough(global_stack): global_stack.userChanges = layer_height_5 assert global_stack.getProperty("layer_height", "value") == 5 +def test_getPropertyWithResolve(global_stack): + #Define some containers for the stack. + resolve = unittest.mock.MagicMock() #Sets just the resolve for bed temperature. + resolve.getProperty = lambda key, property: 15 if (key == "material_bed_temperature" and property == "resolve") else None + resolve_and_value = unittest.mock.MagicMock() #Sets the resolve and value for bed temperature. + resolve_and_value.getProperty = lambda key, property: (7.5 if property == "resolve" else 5) if (key == "material_bed_temperature") else None #7.5 resolve, 5 value. + value = unittest.mock.MagicMock() #Sets just the value for bed temperature. + value.getProperty = lambda key, property: 10 if (key == "material_bed_temperature" and property == "value") else None + empty = unittest.mock.MagicMock() #Sets no value or resolve. + empty.getProperty = unittest.mock.MagicMock(return_value = None) + + global_stack.definition = resolve_and_value + assert global_stack.getProperty("material_bed_temperature", "value") == 7.5 #Resolve wins in the definition. + global_stack.userChanges = resolve_and_value + assert global_stack.getProperty("material_bed_temperature", "value") == 5 #Value wins in other places. + global_stack.userChanges = value + assert global_stack.getProperty("material_bed_temperature", "value") == 10 #Resolve in the definition doesn't influence the value in the user changes. + global_stack.userChanges = resolve + assert global_stack.getProperty("material_bed_temperature", "value") == 15 #Falls through to definition for lack of values, but then asks the start of the stack for the resolve. + global_stack.userChanges = empty + global_stack.qualityChanges = resolve_and_value + assert global_stack.getProperty("material_bed_temperature", "value") == 5 #Value still wins in lower places, except definition. + global_stack.qualityChanges = empty + global_stack.quality = resolve_and_value + assert global_stack.getProperty("material_bed_temperature", "value") == 5 + global_stack.quality = empty + global_stack.material = resolve_and_value + assert global_stack.getProperty("material_bed_temperature", "value") == 5 + global_stack.material = empty + global_stack.variant = resolve_and_value + assert global_stack.getProperty("material_bed_temperature", "value") == 5 + global_stack.variant = empty + global_stack.definitionChanges = resolve_and_value + assert global_stack.getProperty("material_bed_temperature", "value") == 5 + ## Tests whether the hasUserValue returns true for settings that are changed in # the user-changes container. def test_hasUserValueUserChanges(global_stack):