From 79f6e49280d7e684f5191097d3337f0f30e702a0 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 23 Mar 2017 15:00:26 +0100 Subject: [PATCH] Add test for seeing whether variants are properly found Whether the deserialize function finds the variants properly. Contributes to issue CURA-3497. --- tests/Settings/TestGlobalStack.py | 23 +++++++++++++++++++- tests/Settings/stacks/OnlyVariant.global.cfg | 8 +++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/Settings/stacks/OnlyVariant.global.cfg diff --git a/tests/Settings/TestGlobalStack.py b/tests/Settings/TestGlobalStack.py index a1242bc61d..84d1de01b4 100644 --- a/tests/Settings/TestGlobalStack.py +++ b/tests/Settings/TestGlobalStack.py @@ -122,4 +122,25 @@ def test_deserializeMaterial(filename, material_id, container_registry): stack.deserialize(serialized) - assert stack.material.getId() == material_id \ No newline at end of file + assert stack.material.getId() == material_id + +## Tests whether the variant profile is being read properly from a global +# stack. +@pytest.mark.parametrize("filename, variant_id", [ + ("Global.global.cfg", "empty"), + ("Global.stack.cfg", "empty"), + ("MachineLegacy.stack.cfg", "empty"), + ("OnlyVariant.global.cfg", "some_instance"), + ("Complete.global.cfg", "some_variant") +]) +def test_deserializeVariant(filename, variant_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.variant.getId() == variant_id \ No newline at end of file diff --git a/tests/Settings/stacks/OnlyVariant.global.cfg b/tests/Settings/stacks/OnlyVariant.global.cfg new file mode 100644 index 0000000000..dde3276ff5 --- /dev/null +++ b/tests/Settings/stacks/OnlyVariant.global.cfg @@ -0,0 +1,8 @@ +[general] +version = 3 +name = Only Material +id = OnlyMaterial + +[containers] +4 = some_instance +6 = some_definition