Jaime van Kessel 7 лет назад
Родитель
Сommit
69c3baf87f
2 измененных файлов с 8 добавлено и 3 удалено
  1. 1 1
      cura/Settings/CuraContainerStack.py
  2. 7 2
      tests/Settings/TestCuraContainerRegistry.py

+ 1 - 1
cura/Settings/CuraContainerStack.py

@@ -351,7 +351,7 @@ class CuraContainerStack(ContainerStack):
 
 
             if type_name == "definition":
             if type_name == "definition":
                 if not container or not isinstance(container, DefinitionContainer):
                 if not container or not isinstance(container, DefinitionContainer):
-                    definition = self.findContainer(container_type = DefinitionContainer, category = "*")
+                    definition = self.findContainer(container_type = DefinitionContainer)
                     if not definition:
                     if not definition:
                         raise InvalidContainerStackError("Stack {id} does not have a definition!".format(id = self._id))
                         raise InvalidContainerStackError("Stack {id} does not have a definition!".format(id = self._id))
 
 

+ 7 - 2
tests/Settings/TestCuraContainerRegistry.py

@@ -13,6 +13,7 @@ from cura.Settings.GlobalStack import GlobalStack #Testing for returning the cor
 from UM.Resources import Resources #Mocking some functions of this.
 from UM.Resources import Resources #Mocking some functions of this.
 import UM.Settings.ContainerRegistry #Making empty container stacks.
 import UM.Settings.ContainerRegistry #Making empty container stacks.
 import UM.Settings.ContainerStack #Setting the container registry here properly.
 import UM.Settings.ContainerStack #Setting the container registry here properly.
+from UM.Settings.DefinitionContainer import DefinitionContainer
 
 
 ##  Gives a fresh CuraContainerRegistry instance.
 ##  Gives a fresh CuraContainerRegistry instance.
 @pytest.fixture()
 @pytest.fixture()
@@ -37,11 +38,15 @@ def test_loadTypes(filename, output_class, container_registry):
     #Mock some dependencies.
     #Mock some dependencies.
     UM.Settings.ContainerStack.setContainerRegistry(container_registry)
     UM.Settings.ContainerStack.setContainerRegistry(container_registry)
     Resources.getAllResourcesOfType = unittest.mock.MagicMock(return_value = [os.path.join(os.path.dirname(os.path.abspath(__file__)), "stacks", filename)]) #Return just this tested file.
     Resources.getAllResourcesOfType = unittest.mock.MagicMock(return_value = [os.path.join(os.path.dirname(os.path.abspath(__file__)), "stacks", filename)]) #Return just this tested file.
-    def findContainers(id, container_type = 0):
-        if id == "some_instance" or id == "some_definition":
+
+    def findContainers(container_type = 0, id = None):
+        if id == "some_instance":
             return [UM.Settings.ContainerRegistry._EmptyInstanceContainer(id)]
             return [UM.Settings.ContainerRegistry._EmptyInstanceContainer(id)]
+        elif id == "some_definition":
+            return [DefinitionContainer(container_id = id)]
         else:
         else:
             return []
             return []
+
     container_registry.findContainers = findContainers
     container_registry.findContainers = findContainers
 
 
     with unittest.mock.patch("cura.Settings.GlobalStack.GlobalStack.findContainer"):
     with unittest.mock.patch("cura.Settings.GlobalStack.GlobalStack.findContainer"):