From eeb84ac27b924903c10f6a9a1169e57b481256be Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 24 Mar 2017 15:11:25 +0100 Subject: [PATCH] Add tests for prohibited operations on extruder stacks These operations are explicitly prohibited, so they should raise an exception. Contributes to issue CURA-3497. --- tests/Settings/TestExtruderStack.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/Settings/TestExtruderStack.py diff --git a/tests/Settings/TestExtruderStack.py b/tests/Settings/TestExtruderStack.py new file mode 100644 index 0000000000..f081a8cd2a --- /dev/null +++ b/tests/Settings/TestExtruderStack.py @@ -0,0 +1,28 @@ +# Copyright (c) 2017 Ultimaker B.V. +# Cura is released under the terms of the AGPLv3 or higher. + +import pytest #This module contains automated tests. +import unittest.mock #For the mocking and monkeypatching functionality. + +import cura.Settings.ExtruderStack #The module we're testing. +from cura.Settings.Exceptions import InvalidOperationError #To check whether the correct exceptions are raised. + +## An empty extruder stack to test with. +@pytest.fixture() +def extruder_stack() -> cura.Settings.ExtruderStack.ExtruderStack: + return cura.Settings.ExtruderStack.ExtruderStack + +## Tests whether adding a container is properly forbidden. +def test_addContainer(extruder_stack): + with pytest.raises(InvalidOperationError): + extruder_stack.addContainer(unittest.mock.MagicMock()) + +## Tests whether inserting a container is properly forbidden. +def test_insertContainer(extruder_stack): + with pytest.raises(InvalidOperationError): + extruder_stack.insertContainer(0, unittest.mock.MagicMock()) + +## Tests whether removing a container is properly forbidden. +def test_removeContainer(extruder_stack): + with pytest.raises(InvalidOperationError): + extruder_stack.removeContainer(unittest.mock.MagicMock()) \ No newline at end of file