mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 07:33:57 -06:00
Add test to verify that you can't change types of containers
For instance, you shouldn't be able to put an instance container in the definition slot. Contributes to issue CURA-3497.
This commit is contained in:
parent
d1dc48d7e1
commit
00c1c2dcf6
1 changed files with 32 additions and 1 deletions
|
@ -6,8 +6,9 @@ import pytest #This module contains unit tests.
|
||||||
import unittest.mock #To monkeypatch some mocks in place of dependencies.
|
import unittest.mock #To monkeypatch some mocks in place of dependencies.
|
||||||
|
|
||||||
import cura.Settings.GlobalStack #The module we're testing.
|
import cura.Settings.GlobalStack #The module we're testing.
|
||||||
from cura.Settings.Exceptions import TooManyExtrudersError, InvalidOperationError #To test raising these errors.
|
from cura.Settings.Exceptions import TooManyExtrudersError, InvalidContainerError, InvalidOperationError #To test raising these errors.
|
||||||
from UM.Settings.DefinitionContainer import DefinitionContainer #To test against the class DefinitionContainer.
|
from UM.Settings.DefinitionContainer import DefinitionContainer #To test against the class DefinitionContainer.
|
||||||
|
from UM.Settings.InstanceContainer import InstanceContainer #To test against the class InstanceContainer.
|
||||||
import UM.Settings.ContainerRegistry
|
import UM.Settings.ContainerRegistry
|
||||||
import UM.Settings.ContainerStack
|
import UM.Settings.ContainerStack
|
||||||
|
|
||||||
|
@ -67,6 +68,36 @@ def test_addExtruder(global_stack):
|
||||||
with pytest.raises(TooManyExtrudersError): #Should be limited to 2 extruders because of machine_extruder_count.
|
with pytest.raises(TooManyExtrudersError): #Should be limited to 2 extruders because of machine_extruder_count.
|
||||||
global_stack.addExtruder(unittest.mock.MagicMock())
|
global_stack.addExtruder(unittest.mock.MagicMock())
|
||||||
|
|
||||||
|
## Tests whether the container types are properly enforced on the stack.
|
||||||
|
#
|
||||||
|
# When setting a field to have a different type of stack than intended, we
|
||||||
|
# should get an exception.
|
||||||
|
def test_constrainContainerTypes(global_stack):
|
||||||
|
definition_container = DefinitionContainer(container_id = "TestDefinitionContainer")
|
||||||
|
instance_container = InstanceContainer(container_id = "TestInstanceContainer")
|
||||||
|
|
||||||
|
with pytest.raises(InvalidContainerError): #Putting a definition container in the user changes is not allowed.
|
||||||
|
global_stack.userChanges = definition_container
|
||||||
|
global_stack.userChanges = instance_container #Putting an instance container in the user changes is allowed.
|
||||||
|
with pytest.raises(InvalidContainerError):
|
||||||
|
global_stack.qualityChanges = definition_container
|
||||||
|
global_stack.qualityChanges = instance_container
|
||||||
|
with pytest.raises(InvalidContainerError):
|
||||||
|
global_stack.quality = definition_container
|
||||||
|
global_stack.quality = instance_container
|
||||||
|
with pytest.raises(InvalidContainerError):
|
||||||
|
global_stack.material = definition_container
|
||||||
|
global_stack.material = instance_container
|
||||||
|
with pytest.raises(InvalidContainerError):
|
||||||
|
global_stack.variant = definition_container
|
||||||
|
global_stack.variant = instance_container
|
||||||
|
with pytest.raises(InvalidContainerError):
|
||||||
|
global_stack.definitionChanges = definition_container
|
||||||
|
global_stack.definitionChanges = instance_container
|
||||||
|
with pytest.raises(InvalidContainerError): #Putting an instance container in the definition is not allowed.
|
||||||
|
global_stack.definition = instance_container
|
||||||
|
global_stack.definition = definition_container #Putting a definition container in the definition is allowed.
|
||||||
|
|
||||||
## Tests whether the user changes are being read properly from a global stack.
|
## Tests whether the user changes are being read properly from a global stack.
|
||||||
@pytest.mark.parametrize("filename, user_changes_id", [
|
@pytest.mark.parametrize("filename, user_changes_id", [
|
||||||
("Global.global.cfg", "empty"),
|
("Global.global.cfg", "empty"),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue