Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGhostkeeper <rubend@tutanota.com>2017-05-12 16:59:38 +0300
committerGhostkeeper <rubend@tutanota.com>2017-05-12 16:59:38 +0300
commite50b0884f09c032530cf518474ca9c7c4a9ff99d (patch)
treea3b330fa227c37b27fc94f1cb633d7245b198d42 /tests
parentadefbaf72ea6ed4b84a0c807294c6368f606458c (diff)
Add test for registring containers
This test tests adding container stacks and seeing if they convert well. Contributes to issue CURA-3427.
Diffstat (limited to 'tests')
-rw-r--r--tests/Settings/TestCuraContainerRegistry.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/Settings/TestCuraContainerRegistry.py b/tests/Settings/TestCuraContainerRegistry.py
index 7b191a8376..031875df8c 100644
--- a/tests/Settings/TestCuraContainerRegistry.py
+++ b/tests/Settings/TestCuraContainerRegistry.py
@@ -11,6 +11,7 @@ from cura.Settings.CuraContainerRegistry import CuraContainerRegistry #The class
from cura.Settings.ExtruderStack import ExtruderStack #Testing for returning the correct types of stacks.
from cura.Settings.GlobalStack import GlobalStack #Testing for returning the correct types of stacks.
from UM.Resources import Resources #Mocking some functions of this.
+import UM.Settings.InstanceContainer #Creating instance containers to register.
import UM.Settings.ContainerRegistry #Making empty container stacks.
import UM.Settings.ContainerStack #Setting the container registry here properly.
from UM.Settings.DefinitionContainer import DefinitionContainer
@@ -18,7 +19,10 @@ from UM.Settings.DefinitionContainer import DefinitionContainer
## Gives a fresh CuraContainerRegistry instance.
@pytest.fixture()
def container_registry():
- return CuraContainerRegistry()
+ registry = CuraContainerRegistry()
+ UM.Settings.InstanceContainer.setContainerRegistry(registry)
+ UM.Settings.ContainerStack.setContainerRegistry(registry)
+ return registry
def teardown():
#If the temporary file for the legacy file rename test still exists, remove it.
@@ -26,6 +30,23 @@ def teardown():
if os.path.isfile(temporary_file):
os.remove(temporary_file)
+## Tests whether the addContainer function properly converts ContainerStacks.
+def test_addContainerExtruderStack(container_registry):
+ definition = DefinitionContainer(container_id = "Test Definition") #Need some definition first to be able to register stacks.
+ container_registry.addContainer(definition)
+
+ container_stack = UM.Settings.ContainerStack.ContainerStack(stack_id = "Test Container Stack") #A container we're going to convert.
+ container_stack.addMetaDataEntry("type", "extruder_train") #This is now an extruder train.
+ container_stack.insertContainer(0, definition) #Add a definition to it so it doesn't complain.
+
+ mock_super_add_container = unittest.mock.MagicMock()
+ with unittest.mock.patch("UM.Settings.ContainerRegistry.ContainerRegistry.addContainer", mock_super_add_container):
+ container_registry.addContainer(container_stack)
+
+ assert len(mock_super_add_container.call_args_list) == 1 #Called only once.
+ assert len(mock_super_add_container.call_args_list[0][0]) == 1 #Called with one parameter.
+ assert type(mock_super_add_container.call_args_list[0][0][0]) == ExtruderStack
+
## Tests whether loading gives objects of the correct type.
@pytest.mark.parametrize("filename, output_class", [
("ExtruderLegacy.stack.cfg", ExtruderStack),