Browse Source

PyTest fix: The extruder stack test is failed

Aleksei S 7 years ago
parent
commit
47925ec3bc
1 changed files with 7 additions and 4 deletions
  1. 7 4
      tests/Settings/TestExtruderStack.py

+ 7 - 4
tests/Settings/TestExtruderStack.py

@@ -15,6 +15,7 @@ from cura.Settings.Exceptions import InvalidContainerError, InvalidOperationErro
 
 from cura.Settings.ExtruderManager import ExtruderManager
 from UM.Settings.ContainerRegistry import ContainerRegistry
+from cura.Settings.GlobalStack import GlobalStack
 
 ##  Fake container registry that always provides all containers you ask of.
 @pytest.yield_fixture()
@@ -252,7 +253,7 @@ def test_deserializeMoveInstanceContainer(extruder_stack):
 
     assert extruder_stack.quality.getId() == "empty"
     assert extruder_stack.material.getId() != "empty"
-
+from UM.Settings.Validator import Validator
 ##  Tests whether a definition container in the wrong spot is moved into the
 #   correct spot by deserialising.
 @pytest.mark.skip #The test currently fails because the definition container doesn't have a category, which is wrong but we don't have time to refactor that right now.
@@ -279,8 +280,8 @@ def test_getPropertyFallThrough(extruder_stack):
     container_indices = cura.Settings.CuraContainerStack._ContainerIndexes #Cache.
     for type_id, type_name in container_indices.IndexTypeMap.items():
         container = unittest.mock.MagicMock()
-        # Return type_id when asking for value and -1 when asking for limit_to_extruder
-        container.getProperty = lambda key, property, context = None, type_id = type_id: type_id if (key == "layer_height" and property == "value") else (None if property != "limit_to_extruder" else "-1") #Returns the container type ID as layer height, in order to identify it.
+        # Return type_id when asking for value and -1 when asking for settable_per_extruder
+        container.getProperty = lambda key, property, context = None, type_id = type_id: type_id if (key == "layer_height" and property == "value") else (None if property != "settable_per_extruder" else "-1") #Returns the container type ID as layer height, in order to identify it.
         container.hasProperty = lambda key, property: key == "layer_height"
         container.getMetaDataEntry = unittest.mock.MagicMock(return_value = type_name)
         mock_layer_heights[type_id] = container
@@ -298,7 +299,9 @@ def test_getPropertyFallThrough(extruder_stack):
     extruder_stack.variant = mock_no_settings[container_indices.Variant]
     with unittest.mock.patch("cura.Settings.CuraContainerStack.DefinitionContainer", unittest.mock.MagicMock): #To guard against the type checking.
         extruder_stack.definition = mock_layer_heights[container_indices.Definition] #There's a layer height in here!
-    extruder_stack.setNextStack(unittest.mock.MagicMock())
+
+    stack = GlobalStack("PyTest GlobalStack")
+    extruder_stack.setNextStack(stack)
 
     assert extruder_stack.getProperty("layer_height", "value") == container_indices.Definition
     extruder_stack.variant = mock_layer_heights[container_indices.Variant]