mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 18:49:02 +08:00
Add tests for deserialising extruders with variants
Contributes to issue CURA-3497.
This commit is contained in:
parent
bbd0ca7b9f
commit
df2ae12ca9
@ -136,6 +136,26 @@ def test_deserializeUserChanges(filename, user_changes_id, container_registry, e
|
|||||||
#Restore.
|
#Restore.
|
||||||
UM.Settings.ContainerStack._containerRegistry = original_container_registry
|
UM.Settings.ContainerStack._containerRegistry = original_container_registry
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("filename, variant_id", [
|
||||||
|
("Left.extruder.cfg", "empty"),
|
||||||
|
("ExtruderLegacy.stack.cfg", "empty"),
|
||||||
|
("OnlyVariant.extruder.cfg", "some_instance"),
|
||||||
|
("Complete.extruder.cfg", "some_variant")
|
||||||
|
])
|
||||||
|
def test_deserializeVariant(filename, variant_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.variant.getId() == variant_id
|
||||||
|
|
||||||
|
#Restore.
|
||||||
|
UM.Settings.ContainerStack._containerRegistry = original_container_registry
|
||||||
|
|
||||||
## Tests whether inserting a container is properly forbidden.
|
## Tests whether inserting a container is properly forbidden.
|
||||||
def test_insertContainer(extruder_stack):
|
def test_insertContainer(extruder_stack):
|
||||||
with pytest.raises(InvalidOperationError):
|
with pytest.raises(InvalidOperationError):
|
||||||
|
8
tests/Settings/stacks/OnlyVariant.extruder.cfg
Normal file
8
tests/Settings/stacks/OnlyVariant.extruder.cfg
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[general]
|
||||||
|
version = 3
|
||||||
|
name = Only Variant
|
||||||
|
id = OnlyVariant
|
||||||
|
|
||||||
|
[containers]
|
||||||
|
4 = some_instance
|
||||||
|
5 = some_definition
|
Loading…
x
Reference in New Issue
Block a user