mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-09 07:56:22 -06:00
Add tests for setMeterialById
One for when the ID exists, one for when it doesn't exist. Contributes to issue CURA-3497.
This commit is contained in:
parent
3e437074ae
commit
d9ba848dc8
1 changed files with 22 additions and 6 deletions
|
@ -401,7 +401,7 @@ def test_removeContainer(global_stack):
|
||||||
with pytest.raises(InvalidOperationError):
|
with pytest.raises(InvalidOperationError):
|
||||||
global_stack.removeContainer(unittest.mock.MagicMock())
|
global_stack.removeContainer(unittest.mock.MagicMock())
|
||||||
|
|
||||||
## Tests adding a definition by specifying an ID of a definition that exists.
|
## Tests setting definitions by specifying an ID of a definition that exists.
|
||||||
def test_setDefinitionByIdExists(global_stack, container_registry):
|
def test_setDefinitionByIdExists(global_stack, container_registry):
|
||||||
original_container_registry = UM.Settings.ContainerStack._containerRegistry
|
original_container_registry = UM.Settings.ContainerStack._containerRegistry
|
||||||
UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all the profiles you ask of.
|
UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all the profiles you ask of.
|
||||||
|
@ -411,13 +411,13 @@ def test_setDefinitionByIdExists(global_stack, container_registry):
|
||||||
#Restore.
|
#Restore.
|
||||||
UM.Settings.ContainerStack._containerRegistry = original_container_registry
|
UM.Settings.ContainerStack._containerRegistry = original_container_registry
|
||||||
|
|
||||||
## Tests adding a definition by specifying an ID of a definition that doesn't
|
## Tests setting definitions by specifying an ID of a definition that doesn't
|
||||||
# exist.
|
# exist.
|
||||||
def test_setDefinitionByIdDoesntExist(global_stack):
|
def test_setDefinitionByIdDoesntExist(global_stack):
|
||||||
with pytest.raises(KeyError):
|
with pytest.raises(KeyError):
|
||||||
global_stack.setDefinitionById("some_definition") #Container registry is empty now.
|
global_stack.setDefinitionById("some_definition") #Container registry is empty now.
|
||||||
|
|
||||||
## Tests adding definition changes by specifying an ID of a container that
|
## Tests setting definition changes by specifying an ID of a container that
|
||||||
# exists.
|
# exists.
|
||||||
def test_setDefinitionChangesByIdExists(global_stack, container_registry):
|
def test_setDefinitionChangesByIdExists(global_stack, container_registry):
|
||||||
original_container_registry = UM.Settings.ContainerStack._containerRegistry
|
original_container_registry = UM.Settings.ContainerStack._containerRegistry
|
||||||
|
@ -428,12 +428,28 @@ def test_setDefinitionChangesByIdExists(global_stack, container_registry):
|
||||||
#Restore.
|
#Restore.
|
||||||
UM.Settings.ContainerStack._containerRegistry = original_container_registry
|
UM.Settings.ContainerStack._containerRegistry = original_container_registry
|
||||||
|
|
||||||
## Tests adding definition changes by specifying an ID of a container that
|
## Tests setting definition changes by specifying an ID of a container that
|
||||||
# doesn't exist.
|
# doesn't exist.
|
||||||
def test_setDefinitionChangesByIdDoesntExist(global_stack):
|
def test_setDefinitionChangesByIdDoesntExist(global_stack):
|
||||||
with pytest.raises(KeyError):
|
with pytest.raises(KeyError):
|
||||||
global_stack.setDefinitionChangesById("some_definition_changes") #Container registry is empty now.
|
global_stack.setDefinitionChangesById("some_definition_changes") #Container registry is empty now.
|
||||||
|
|
||||||
|
## Tests setting materials by specifying an ID of a material that exists.
|
||||||
|
def test_setMaterialByIdExists(global_stack, container_registry):
|
||||||
|
original_container_registry = UM.Settings.ContainerStack._containerRegistry
|
||||||
|
UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all the profiles you ask of.
|
||||||
|
|
||||||
|
global_stack.setMaterialById("some_material") #The container registry always has a container with the ID.
|
||||||
|
|
||||||
|
#Restore.
|
||||||
|
UM.Settings.ContainerStack._containerRegistry = original_container_registry
|
||||||
|
|
||||||
|
## Tests setting materials by specifying an ID of a material that doesn't
|
||||||
|
# exist.
|
||||||
|
def test_setMaterialByIdDoesntExist(global_stack):
|
||||||
|
with pytest.raises(KeyError):
|
||||||
|
global_stack.setMaterialById("some_material") #Container registry is empty now.
|
||||||
|
|
||||||
## Tests whether changing the next stack is properly forbidden.
|
## Tests whether changing the next stack is properly forbidden.
|
||||||
def test_setNextStack(global_stack):
|
def test_setNextStack(global_stack):
|
||||||
with pytest.raises(InvalidOperationError):
|
with pytest.raises(InvalidOperationError):
|
||||||
|
@ -480,7 +496,7 @@ def test_setPropertyOtherContainers(target_container, global_stack):
|
||||||
}
|
}
|
||||||
assert containers[target_container].getProperty(key, property) == output_value
|
assert containers[target_container].getProperty(key, property) == output_value
|
||||||
|
|
||||||
## Tests adding a variant by specifying an ID of a variant that exists.
|
## Tests setting variants by specifying an ID of a variant that exists.
|
||||||
def test_setVariantByIdExists(global_stack, container_registry):
|
def test_setVariantByIdExists(global_stack, container_registry):
|
||||||
original_container_registry = UM.Settings.ContainerStack._containerRegistry
|
original_container_registry = UM.Settings.ContainerStack._containerRegistry
|
||||||
UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all the profiles you ask of.
|
UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all the profiles you ask of.
|
||||||
|
@ -490,7 +506,7 @@ def test_setVariantByIdExists(global_stack, container_registry):
|
||||||
#Restore.
|
#Restore.
|
||||||
UM.Settings.ContainerStack._containerRegistry = original_container_registry
|
UM.Settings.ContainerStack._containerRegistry = original_container_registry
|
||||||
|
|
||||||
## Tests adding a variant by specifying an ID of a variant that doesn't exist.
|
## Tests setting variants by specifying an ID of a variant that doesn't exist.
|
||||||
def test_setVariantByIdDoesntExist(global_stack):
|
def test_setVariantByIdDoesntExist(global_stack):
|
||||||
with pytest.raises(KeyError):
|
with pytest.raises(KeyError):
|
||||||
global_stack.setVariantById("some_variant") #Container registry is empty now.
|
global_stack.setVariantById("some_variant") #Container registry is empty now.
|
Loading…
Add table
Add a link
Reference in a new issue