Remove unused target_container parameter

It's not compatible with ContainerInterface anyway.

Contributes to issue CURA-5330.
This commit is contained in:
Ghostkeeper 2018-06-01 13:32:59 +02:00
parent a6ffbbde8f
commit e38228ac24
No known key found for this signature in database
GPG key ID: 5252B696FB5E7C7A
3 changed files with 8 additions and 57 deletions

View file

@ -1,7 +1,7 @@
# Copyright (c) 2018 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
from typing import Any, List, Optional
from typing import Any, List, Optional, Union
from PyQt5.QtCore import pyqtProperty, pyqtSignal, QObject
from UM.Application import Application
@ -36,7 +36,7 @@ from . import Exceptions
# This also means that operations on the stack that modifies the container ordering is prohibited and
# will raise an exception.
class CuraContainerStack(ContainerStack):
def __init__(self, container_id: str):
def __init__(self, container_id: str) -> None:
super().__init__(container_id)
self._container_registry = ContainerRegistry.getInstance() #type: ContainerRegistry
@ -48,7 +48,7 @@ class CuraContainerStack(ContainerStack):
self._empty_material = self._container_registry.findInstanceContainers(id = "empty_material")[0] #type: InstanceContainer
self._empty_variant = self._container_registry.findInstanceContainers(id = "empty_variant")[0] #type: InstanceContainer
self._containers = [self._empty_instance_container for i in range(len(_ContainerIndexes.IndexTypeMap))] #type: List[ContainerInterface]
self._containers = [self._empty_instance_container for i in range(len(_ContainerIndexes.IndexTypeMap))] #type: List[Union[InstanceContainer, DefinitionContainer]]
self._containers[_ContainerIndexes.QualityChanges] = self._empty_quality_changes
self._containers[_ContainerIndexes.Quality] = self._empty_quality
self._containers[_ContainerIndexes.Material] = self._empty_material
@ -186,13 +186,9 @@ class CuraContainerStack(ContainerStack):
# \param key The key of the setting to set.
# \param property_name The name of the property to set.
# \param new_value The new value to set the property to.
# \param target_container The type of the container to set the property of. Defaults to "user".
def setProperty(self, key: str, property_name: str, new_value: Any, target_container: str = "user") -> None:
container_index = _ContainerIndexes.TypeIndexMap.get(target_container, -1)
if container_index != -1:
def setProperty(self, key: str, property_name: str, new_value: Any) -> None:
container_index = _ContainerIndexes.UserChanges
self._containers[container_index].setProperty(key, property_name, new_value)
else:
raise IndexError("Invalid target container {type}".format(type = target_container))
## Overridden from ContainerStack
#

View file

@ -341,25 +341,3 @@ def test_setPropertyUser(key, property, value, extruder_stack):
extruder_stack.setProperty(key, property, value) #The actual test.
extruder_stack.userChanges.setProperty.assert_called_once_with(key, property, value) #Make sure that the user container gets a setProperty call.
## Tests setting properties on specific containers on the global stack.
@pytest.mark.parametrize("target_container, stack_variable", [
("user", "userChanges"),
("quality_changes", "qualityChanges"),
("quality", "quality"),
("material", "material"),
("variant", "variant")
])
def test_setPropertyOtherContainers(target_container, stack_variable, extruder_stack):
#Other parameters that don't need to be varied.
key = "layer_height"
property = "value"
value = 0.1337
#A mock container in the right spot.
container = unittest.mock.MagicMock()
container.getMetaDataEntry = unittest.mock.MagicMock(return_value = target_container)
setattr(extruder_stack, stack_variable, container) #For instance, set global_stack.qualityChanges = container.
extruder_stack.setProperty(key, property, value, target_container = target_container) #The actual test.
getattr(extruder_stack, stack_variable).setProperty.assert_called_once_with(key, property, value) #Make sure that the proper container gets a setProperty call.

View file

@ -482,26 +482,3 @@ def test_setPropertyUser(key, property, value, global_stack):
global_stack.setProperty(key, property, value) #The actual test.
global_stack.userChanges.setProperty.assert_called_once_with(key, property, value) #Make sure that the user container gets a setProperty call.
## Tests setting properties on specific containers on the global stack.
@pytest.mark.parametrize("target_container, stack_variable", [
("user", "userChanges"),
("quality_changes", "qualityChanges"),
("quality", "quality"),
("material", "material"),
("variant", "variant"),
("definition_changes", "definitionChanges")
])
def test_setPropertyOtherContainers(target_container, stack_variable, global_stack):
#Other parameters that don't need to be varied.
key = "layer_height"
property = "value"
value = 0.1337
#A mock container in the right spot.
container = unittest.mock.MagicMock()
container.getMetaDataEntry = unittest.mock.MagicMock(return_value = target_container)
setattr(global_stack, stack_variable, container) #For instance, set global_stack.qualityChanges = container.
global_stack.setProperty(key, property, value, target_container = target_container) #The actual test.
getattr(global_stack, stack_variable).setProperty.assert_called_once_with(key, property, value) #Make sure that the proper container gets a setProperty call.