From eb7035db4514909622f37defee0cd8b8c3bc0307 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 24 Mar 2017 17:46:59 +0100 Subject: [PATCH] Add tests for setMaterialById One for when the ID exists, and one for when it doesn't. Contributes to issue CURA-3497. --- tests/Settings/TestExtruderStack.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/Settings/TestExtruderStack.py b/tests/Settings/TestExtruderStack.py index e6d53b7b1f..2327e2d5bb 100644 --- a/tests/Settings/TestExtruderStack.py +++ b/tests/Settings/TestExtruderStack.py @@ -290,4 +290,20 @@ def test_setDefinitionByIdExists(extruder_stack, container_registry): # exist. def test_setDefinitionByIdDoesntExist(extruder_stack): with pytest.raises(KeyError): - extruder_stack.setDefinitionById("some_definition") #Container registry is empty now. \ No newline at end of file + extruder_stack.setDefinitionById("some_definition") #Container registry is empty now. + +## Tests setting materials by specifying an ID of a material that exists. +def test_setMaterialByIdExists(extruder_stack, container_registry): + original_container_registry = UM.Settings.ContainerStack._containerRegistry + UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all the profiles you ask of. + + extruder_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(extruder_stack): + with pytest.raises(KeyError): + extruder_stack.setMaterialById("some_material") #Container registry is empty now. \ No newline at end of file