mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-22 06:03:57 -06:00
Add test for addExtruder
This mainly tests if it is properly limited by the number of extruders setting. Contributes to issue CURA-3497.
This commit is contained in:
parent
86a1d3eb10
commit
d40a67f2b0
1 changed files with 13 additions and 0 deletions
|
@ -6,6 +6,7 @@ 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 #To test raising this error.
|
||||||
from UM.Settings.DefinitionContainer import DefinitionContainer #To test against the class DefinitionContainer.
|
from UM.Settings.DefinitionContainer import DefinitionContainer #To test against the class DefinitionContainer.
|
||||||
import UM.Settings.ContainerRegistry
|
import UM.Settings.ContainerRegistry
|
||||||
import UM.Settings.ContainerStack
|
import UM.Settings.ContainerStack
|
||||||
|
@ -49,6 +50,18 @@ def readStack(filename):
|
||||||
|
|
||||||
#############################START OF TEST CASES################################
|
#############################START OF TEST CASES################################
|
||||||
|
|
||||||
|
## Tests adding extruders to the global stack.
|
||||||
|
def test_addExtruder(global_stack):
|
||||||
|
mock_definition = unittest.mock.MagicMock()
|
||||||
|
mock_definition.getProperty = lambda key, property: 2 if key == "machine_extruder_count" and property == "value" else None
|
||||||
|
|
||||||
|
global_stack.definition = mock_definition
|
||||||
|
|
||||||
|
global_stack.addExtruder(unittest.mock.MagicMock())
|
||||||
|
global_stack.addExtruder(unittest.mock.MagicMock())
|
||||||
|
with pytest.raises(TooManyExtrudersError):
|
||||||
|
global_stack.addExtruder(unittest.mock.MagicMock())
|
||||||
|
|
||||||
## 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