Partial fix for intent manager not finding correct profile in test

Only in test.
This commit is contained in:
Ghostkeeper 2019-09-23 15:17:15 +02:00
parent 7d40d962e8
commit 557746a832
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276
4 changed files with 20 additions and 12 deletions

View file

@ -1028,12 +1028,14 @@ class MachineManager(QObject):
def _onMaterialNameChanged(self) -> None: def _onMaterialNameChanged(self) -> None:
self.activeMaterialChanged.emit() self.activeMaterialChanged.emit()
## Get the signals that signal that the containers changed for all stacks.
#
# This includes the global stack and all extruder stacks. So if any
# container changed anywhere.
def _getContainerChangedSignals(self) -> List[Signal]: def _getContainerChangedSignals(self) -> List[Signal]:
if self._global_container_stack is None: if self._global_container_stack is None:
return [] return []
stacks = ExtruderManager.getInstance().getActiveExtruderStacks() return [s.containersChanged for s in ExtruderManager.getInstance().getActiveExtruderStacks() + [self._global_container_stack]]
stacks.append(self._global_container_stack)
return [ s.containersChanged for s in stacks ]
@pyqtSlot(str, str, str) @pyqtSlot(str, str, str)
def setSettingForAllExtruders(self, setting_name: str, property_name: str, property_value: str) -> None: def setSettingForAllExtruders(self, setting_name: str, property_name: str, property_value: str) -> None:

View file

@ -4,8 +4,6 @@ from UM.Settings.DefinitionContainer import DefinitionContainer
from cura.Machines.ContainerTree import ContainerTree from cura.Machines.ContainerTree import ContainerTree
from cura.Settings.GlobalStack import GlobalStack from cura.Settings.GlobalStack import GlobalStack
import cura.CuraApplication # DEBUG!
def createMockedStack(definition_id: str): def createMockedStack(definition_id: str):
result = MagicMock(spec = GlobalStack) result = MagicMock(spec = GlobalStack)

View file

@ -50,10 +50,16 @@ class MockContainer(ContainerInterface, UM.PluginObject.PluginObject):
return default return default
## Gets a human-readable name for this container. ## Gets a human-readable name for this container.
# # \return The name from the metadata, or "MockContainer" if there was no
# \return Always returns "MockContainer". # name provided.
def getName(self): def getName(self):
return "MockContainer" return self._metadata.get("name", "MockContainer")
## Get whether a container stack is enabled or not.
# \return Always returns True.
@property
def isEnabled(self):
return True
## Get whether the container item is stored on a read only location in the filesystem. ## Get whether the container item is stored on a read only location in the filesystem.
# #

View file

@ -21,7 +21,7 @@ mocked_qualitygroup_metadata = {
"normal": QualityGroup("um3_aa4_pla_normal", "normal"), "normal": QualityGroup("um3_aa4_pla_normal", "normal"),
"abnorm": QualityGroup("um3_aa4_pla_abnorm", "abnorm")} # type:Dict[str, QualityGroup] "abnorm": QualityGroup("um3_aa4_pla_abnorm", "abnorm")} # type:Dict[str, QualityGroup]
@pytest.fixture() @pytest.fixture
def mock_container_tree() -> MagicMock: def mock_container_tree() -> MagicMock:
container_tree = MagicMock() container_tree = MagicMock()
container_tree.getCurrentQualityGroups = MagicMock(return_value = mocked_qualitygroup_metadata) container_tree.getCurrentQualityGroups = MagicMock(return_value = mocked_qualitygroup_metadata)
@ -57,7 +57,7 @@ def mock_container_tree() -> MagicMock:
} }
return container_tree return container_tree
@pytest.fixture() @pytest.fixture
def intent_manager(application, extruder_manager, machine_manager, container_registry, global_stack) -> IntentManager: def intent_manager(application, extruder_manager, machine_manager, container_registry, global_stack) -> IntentManager:
application.getExtruderManager = MagicMock(return_value = extruder_manager) application.getExtruderManager = MagicMock(return_value = extruder_manager)
application.getGlobalContainerStack = MagicMock(return_value = global_stack) application.getGlobalContainerStack = MagicMock(return_value = global_stack)
@ -98,16 +98,18 @@ def doSetup(application, extruder_manager, container_registry, global_stack) ->
qualitygroup.node_for_global = MagicMock(name = "Node for global") qualitygroup.node_for_global = MagicMock(name = "Node for global")
global_stack.definition = MockContainer({"id": "ultimaker3"}) global_stack.definition = MockContainer({"id": "ultimaker3"})
application.getGlobalContainerStack = MagicMock(return_value = global_stack)
extruder_stack_a = MockContainer({"id": "Extruder The First"}) extruder_stack_a = MockContainer({"id": "Extruder The First"})
extruder_stack_a.variant = MockContainer({"name": "AA 0.4"}) extruder_stack_a.variant = MockContainer({"name": "AA 0.4"})
extruder_stack_a.quality = MockContainer({"id": "um3_aa4_pla_normal"})
extruder_stack_a.material = MockContainer({"base_file": "generic_pla"}) extruder_stack_a.material = MockContainer({"base_file": "generic_pla"})
extruder_stack_b = MockContainer({"id": "Extruder II: Plastic Boogaloo"}) extruder_stack_b = MockContainer({"id": "Extruder II: Plastic Boogaloo"})
extruder_stack_b.variant = MockContainer({"name": "AA 0.4"}) extruder_stack_b.variant = MockContainer({"name": "AA 0.4"})
extruder_stack_b.quality = MockContainer({"id": "um3_aa4_pla_normal"})
extruder_stack_b.material = MockContainer({"base_file": "generic_pla"}) extruder_stack_b.material = MockContainer({"base_file": "generic_pla"})
global_stack.extruderList = [extruder_stack_a, extruder_stack_b]
application.getGlobalContainerStack().extruderList = [extruder_stack_a, extruder_stack_b] application.getGlobalContainerStack = MagicMock(return_value = global_stack)
extruder_manager.getUsedExtruderStacks = MagicMock(return_value = [extruder_stack_a, extruder_stack_b]) extruder_manager.getUsedExtruderStacks = MagicMock(return_value = [extruder_stack_a, extruder_stack_b])