mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 09:47:50 -06:00
Add tests for prohibited operations
Four of these. It's probably too simple to test now, but who knows what could happen in the future. Contributes to issue CURA-3497.
This commit is contained in:
parent
f2b9f79fb3
commit
56082bdbdf
1 changed files with 21 additions and 2 deletions
|
@ -6,7 +6,7 @@ import pytest #This module contains unit tests.
|
|||
import unittest.mock #To monkeypatch some mocks in place of dependencies.
|
||||
|
||||
import cura.Settings.GlobalStack #The module we're testing.
|
||||
from cura.Settings.Exceptions import TooManyExtrudersError #To test raising this error.
|
||||
from cura.Settings.Exceptions import TooManyExtrudersError, InvalidOperationError #To test raising these errors.
|
||||
from UM.Settings.DefinitionContainer import DefinitionContainer #To test against the class DefinitionContainer.
|
||||
import UM.Settings.ContainerRegistry
|
||||
import UM.Settings.ContainerStack
|
||||
|
@ -50,6 +50,11 @@ def readStack(filename):
|
|||
|
||||
#############################START OF TEST CASES################################
|
||||
|
||||
## Tests whether adding a container is properly forbidden.
|
||||
def test_addContainer(global_stack):
|
||||
with pytest.raises(InvalidOperationError):
|
||||
global_stack.addContainer(unittest.mock.MagicMock())
|
||||
|
||||
## Tests adding extruders to the global stack.
|
||||
def test_addExtruder(global_stack):
|
||||
mock_definition = unittest.mock.MagicMock()
|
||||
|
@ -301,4 +306,18 @@ def test_hasUserValueQualityChanges(global_stack):
|
|||
|
||||
assert not global_stack.hasUserValue("infill_sparse_density")
|
||||
assert global_stack.hasUserValue("layer_height")
|
||||
assert not global_stack.hasUserValue("")
|
||||
assert not global_stack.hasUserValue("")
|
||||
|
||||
## Tests whether inserting a container is properly forbidden.
|
||||
def test_insertContainer(global_stack):
|
||||
with pytest.raises(InvalidOperationError):
|
||||
global_stack.insertContainer(0, unittest.mock.MagicMock())
|
||||
|
||||
def test_removeContainer(global_stack):
|
||||
with pytest.raises(InvalidOperationError):
|
||||
global_stack.removeContainer(unittest.mock.MagicMock())
|
||||
|
||||
## Tests whether changing the next stack is properly forbidden.
|
||||
def test_setNextStack(global_stack):
|
||||
with pytest.raises(InvalidOperationError):
|
||||
global_stack.setNextStack(unittest.mock.MagicMock())
|
Loading…
Add table
Add a link
Reference in a new issue