From 12d1db8f191b275fc2bd90b2ea9d5fd0c6656e1c Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 11 Apr 2017 09:39:18 +0200 Subject: [PATCH] Add test for whether resolve wins in definition I'm splitting the test below up into pieces. It'll be removed eventually, when I've made all of these separate tests. Contributes to issue CURA-3497. --- tests/Settings/TestGlobalStack.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/Settings/TestGlobalStack.py b/tests/Settings/TestGlobalStack.py index b3d814f8c1..ea2169e4e9 100644 --- a/tests/Settings/TestGlobalStack.py +++ b/tests/Settings/TestGlobalStack.py @@ -402,6 +402,17 @@ def test_getPropertyFallThrough(global_stack): global_stack.userChanges = mock_layer_heights[container_indexes.UserChanges] assert global_stack.getProperty("layer_height", "value") == container_indexes.UserChanges +## In definitions, when the value is asked and there is a resolve function, it +# must get the resolve first. +def test_getPropertyResolveInDefinition(global_stack): + 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. + + with unittest.mock.patch("cura.Settings.CuraContainerStack.DefinitionContainer", unittest.mock.MagicMock): #To guard against the type checking. + global_stack.definition = resolve_and_value + assert global_stack.getProperty("material_bed_temperature", "value") == 7.5 #Resolve wins in the definition. + +## Tests whether the resolve property is properly obtained in all cases. @pytest.mark.skip def test_getPropertyWithResolve(global_stack): #Define some containers for the stack.