mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-12 09:17:50 -06:00
Add test to verify priority of resolve property
The resolve property should get priority over the value in the definition container, but not anywhere else. Contributes to issue CURA-3497.
This commit is contained in:
parent
f4673b340a
commit
d1dc48d7e1
1 changed files with 35 additions and 0 deletions
|
@ -280,6 +280,41 @@ def test_getPropertyFallThrough(global_stack):
|
||||||
global_stack.userChanges = layer_height_5
|
global_stack.userChanges = layer_height_5
|
||||||
assert global_stack.getProperty("layer_height", "value") == 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
|
## Tests whether the hasUserValue returns true for settings that are changed in
|
||||||
# the user-changes container.
|
# the user-changes container.
|
||||||
def test_hasUserValueUserChanges(global_stack):
|
def test_hasUserValueUserChanges(global_stack):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue