mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-10 16:27:51 -06:00
Add tests for deserialising extruders with material
Contributes to issue CURA-3497.
This commit is contained in:
parent
9cb7c30fcb
commit
bbd0ca7b9f
3 changed files with 36 additions and 0 deletions
|
@ -55,6 +55,27 @@ def test_addContainer(extruder_stack):
|
||||||
with pytest.raises(InvalidOperationError):
|
with pytest.raises(InvalidOperationError):
|
||||||
extruder_stack.addContainer(unittest.mock.MagicMock())
|
extruder_stack.addContainer(unittest.mock.MagicMock())
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("filename, material_id", [
|
||||||
|
("Left.extruder.cfg", "some_instance"),
|
||||||
|
("ExtruderLegacy.stack.cfg", "some_instance"),
|
||||||
|
("OnlyMaterial.extruder.cfg", "some_instance"),
|
||||||
|
("OnlyDefinition.extruder.cfg", "empty"),
|
||||||
|
("Complete.extruder.cfg", "some_material")
|
||||||
|
])
|
||||||
|
def test_deserializeMaterial(filename, material_id, container_registry, extruder_stack):
|
||||||
|
serialized = readStack(filename)
|
||||||
|
|
||||||
|
#Mock the loading of the instance containers.
|
||||||
|
extruder_stack.findContainer = findSomeContainers
|
||||||
|
original_container_registry = UM.Settings.ContainerStack._containerRegistry
|
||||||
|
UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all profiles you ask of.
|
||||||
|
|
||||||
|
extruder_stack.deserialize(serialized)
|
||||||
|
assert extruder_stack.material.getId() == material_id
|
||||||
|
|
||||||
|
#Restore.
|
||||||
|
UM.Settings.ContainerStack._containerRegistry = original_container_registry
|
||||||
|
|
||||||
@pytest.mark.parametrize("filename, quality_id", [
|
@pytest.mark.parametrize("filename, quality_id", [
|
||||||
("Left.extruder.cfg", "empty"),
|
("Left.extruder.cfg", "empty"),
|
||||||
("ExtruderLegacy.stack.cfg", "empty"),
|
("ExtruderLegacy.stack.cfg", "empty"),
|
||||||
|
|
7
tests/Settings/stacks/OnlyDefinition.extruder.cfg
Normal file
7
tests/Settings/stacks/OnlyDefinition.extruder.cfg
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[general]
|
||||||
|
version = 3
|
||||||
|
name = Only Definition
|
||||||
|
id = OnlyDefinition
|
||||||
|
|
||||||
|
[containers]
|
||||||
|
5 = some_definition
|
8
tests/Settings/stacks/OnlyMaterial.extruder.cfg
Normal file
8
tests/Settings/stacks/OnlyMaterial.extruder.cfg
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[general]
|
||||||
|
version = 3
|
||||||
|
name = Only Material
|
||||||
|
id = OnlyMaterial
|
||||||
|
|
||||||
|
[containers]
|
||||||
|
3 = some_instance
|
||||||
|
5 = some_definition
|
Loading…
Add table
Add a link
Reference in a new issue