Browse Source

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.
Ghostkeeper 8 years ago
parent
commit
95a377d54e

+ 23 - 1
tests/Settings/TestGlobalStack.py

@@ -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

+ 7 - 0
tests/Settings/stacks/OnlyDefinition.global.cfg

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

+ 8 - 0
tests/Settings/stacks/OnlyMaterial.global.cfg

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