Add tests for hasUserValue

These fail at the moment because they also depend on being able to change the stack, which isn't implemented yet.

Contributes to issue CURA-3497.
This commit is contained in:
Ghostkeeper 2017-03-23 16:09:03 +01:00
parent 8a3ab6d289
commit bf2050479b
No known key found for this signature in database
GPG Key ID: C5F96EE2BC0F7E75

View File

@ -186,4 +186,34 @@ def test_deserializeDefinition(filename, definition_id, container_registry):
stack.deserialize(serialized)
assert stack.definition.getId() == definition_id
assert stack.definition.getId() == definition_id
## Tests whether the hasUserValue returns true for settings that are changed in
# the user-changes container.
def test_hasUserValueUserChanges():
user_changes = unittest.mock.MagicMock()
def hasProperty(key, property):
return key == "layer_height" and property == "value" #Only have the layer_height property set.
user_changes.hasProperty = hasProperty
stack = cura.Settings.GlobalStack.GlobalStack("TestStack")
stack.userChanges = user_changes
assert not stack.hasUserValue("infill_sparse_density")
assert stack.hasUserValue("layer_height")
assert not stack.hasUserValue("")
## Tests whether the hasUserValue returns true for settings that are changed in
# the quality-changes container.
def test_hasUserValueQualityChanges():
quality_changes = unittest.mock.MagicMock()
def hasProperty(key, property):
return key == "layer_height" and property == "value" #Only have the layer_height property set.
quality_changes.hasProperty = hasProperty
stack = cura.Settings.GlobalStack.GlobalStack("TestStack")
stack.qualityChanges = quality_changes
assert not stack.hasUserValue("infill_sparse_density")
assert stack.hasUserValue("layer_height")
assert not stack.hasUserValue("")