mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-09 14:55:03 -06:00
Make value unit tests also provide a "state" property
Since we now use state to determine whether we should perform resolve or not.
This commit is contained in:
parent
323107ef5c
commit
93e42164a8
1 changed files with 4 additions and 3 deletions
|
@ -11,6 +11,7 @@ import cura.Settings.CuraContainerStack #To get the list of container types.
|
|||
from cura.Settings.Exceptions import TooManyExtrudersError, InvalidContainerError, InvalidOperationError #To test raising these errors.
|
||||
from UM.Settings.DefinitionContainer import DefinitionContainer #To test against the class DefinitionContainer.
|
||||
from UM.Settings.InstanceContainer import InstanceContainer #To test against the class InstanceContainer.
|
||||
from UM.Settings.SettingInstance import InstanceState
|
||||
import UM.Settings.ContainerRegistry
|
||||
import UM.Settings.ContainerStack
|
||||
|
||||
|
@ -415,7 +416,7 @@ def test_getPropertyNoResolveInDefinition(global_stack):
|
|||
# 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.
|
||||
resolve_and_value.getProperty = lambda key, property: (7.5 if property == "resolve" else 5) if (key == "material_bed_temperature" and property in ("resolve", "value")) 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
|
||||
|
@ -428,7 +429,7 @@ def test_getPropertyResolveInInstance(global_stack):
|
|||
instance_containers = {}
|
||||
for container_type in container_indices.IndexTypeMap:
|
||||
instance_containers[container_type] = unittest.mock.MagicMock() #Sets the resolve and value for bed temperature.
|
||||
instance_containers[container_type].getProperty = lambda key, property: (7.5 if property == "resolve" else 5) if (key == "material_bed_temperature") else None #7.5 resolve, 5 value.
|
||||
instance_containers[container_type].getProperty = lambda key, property: (7.5 if property == "resolve" else (InstanceState.User if property == "state" else 5)) if (key == "material_bed_temperature") else None #7.5 resolve, 5 value.
|
||||
instance_containers[container_type].getMetaDataEntry = unittest.mock.MagicMock(return_value = container_indices.IndexTypeMap[container_type]) #Make queries for the type return the desired type.
|
||||
instance_containers[container_indices.Definition].getProperty = lambda key, property: 10 if (key == "material_bed_temperature" and property == "value") else None #Definition only has value.
|
||||
with unittest.mock.patch("cura.Settings.CuraContainerStack.DefinitionContainer", unittest.mock.MagicMock): #To guard against the type checking.
|
||||
|
@ -452,7 +453,7 @@ def test_getPropertyResolveInInstance(global_stack):
|
|||
# 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.getProperty = lambda key, property: (10 if property == "value" else InstanceState.User) if key == "material_bed_temperature" 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue