Add test for deserialising materials in stacks

Similar to the other tests, but this one is a bit special since the original test stacks had a material defined. Therefore it also defines a separate stack that only has a definition so that we can see if it's fine with the material being empty.

Contributes to issue CURA-3497.
This commit is contained in:
Ghostkeeper 2017-03-22 17:32:37 +01:00
parent 80329ad6e8
commit 95a377d54e
No known key found for this signature in database
GPG Key ID: C5F96EE2BC0F7E75
3 changed files with 38 additions and 1 deletions

View File

@ -100,4 +100,26 @@ def test_deserializeQuality(filename, quality_id, container_registry):
stack.deserialize(serialized)
assert stack.quality.getId() == quality_id
assert stack.quality.getId() == quality_id
## Tests whether the material profile is being read properly from a global
# stack.
@pytest.mark.parametrize("filename, material_id", [
("Global.global.cfg", "some_instance"),
("Global.stack.cfg", "some_instance"),
("MachineLegacy.stack.cfg", "some_instance"),
("OnlyDefinition.global.cfg", "empty"),
("OnlyMaterial.global.cfg", "some_instance"),
("Complete.global.cfg", "some_material")
])
def test_deserializeMaterial(filename, material_id, container_registry):
serialized = readStack(filename)
stack = cura.Settings.GlobalStack.GlobalStack("TestStack")
#Mock the loading of the instance containers.
stack.findContainer = findSomeContainers
UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all the profiles you ask of.
stack.deserialize(serialized)
assert stack.material.getId() == material_id

View File

@ -0,0 +1,7 @@
[general]
version = 3
name = Only Definition
id = OnlyDefinition
[containers]
6 = some_definition

View File

@ -0,0 +1,8 @@
[general]
version = 3
name = Only Material
id = OnlyMaterial
[containers]
3 = some_instance
6 = some_definition