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.
This commit is contained in:
Ghostkeeper 2017-04-11 10:39:07 +02:00
parent 759da2ab05
commit 86b288cc6e
No known key found for this signature in database
GPG key ID: C5F96EE2BC0F7E75

View file

@ -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):