mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-19 15:39:10 +08:00
Merge branch 'transparent_limit_to_extruder' of github.com:ultimaker/Cura into transparent_limit_to_extruder
* 'transparent_limit_to_extruder' of github.com:ultimaker/Cura: Removed unused imports Fixed type hinting for Extruder stack Fixed two remaining failing unit tests Fixes unit fallthrough unit test
This commit is contained in:
commit
c4e6336828
@ -1,22 +1,21 @@
|
|||||||
# Copyright (c) 2017 Ultimaker B.V.
|
# Copyright (c) 2017 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the AGPLv3 or higher.
|
# Cura is released under the terms of the AGPLv3 or higher.
|
||||||
|
|
||||||
from typing import Any
|
from typing import Any, TYPE_CHECKING, Optional
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot
|
|
||||||
|
|
||||||
from UM.Decorators import override
|
from UM.Decorators import override
|
||||||
from UM.MimeTypeDatabase import MimeType, MimeTypeDatabase
|
from UM.MimeTypeDatabase import MimeType, MimeTypeDatabase
|
||||||
from UM.Settings.ContainerStack import ContainerStack, InvalidContainerStackError
|
from UM.Settings.ContainerStack import ContainerStack
|
||||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||||
from UM.Settings.InstanceContainer import InstanceContainer
|
|
||||||
from UM.Settings.DefinitionContainer import DefinitionContainer
|
|
||||||
from UM.Settings.Interfaces import ContainerInterface
|
from UM.Settings.Interfaces import ContainerInterface
|
||||||
|
|
||||||
from . import Exceptions
|
from . import Exceptions
|
||||||
from .CuraContainerStack import CuraContainerStack
|
from .CuraContainerStack import CuraContainerStack
|
||||||
from .ExtruderManager import ExtruderManager
|
from .ExtruderManager import ExtruderManager
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from cura.Settings.GlobalStack import GlobalStack
|
||||||
|
|
||||||
## Represents an Extruder and its related containers.
|
## Represents an Extruder and its related containers.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@ -38,6 +37,10 @@ class ExtruderStack(CuraContainerStack):
|
|||||||
# For backward compatibility: Register the extruder with the Extruder Manager
|
# For backward compatibility: Register the extruder with the Extruder Manager
|
||||||
ExtruderManager.getInstance().registerExtruder(self, stack.id)
|
ExtruderManager.getInstance().registerExtruder(self, stack.id)
|
||||||
|
|
||||||
|
@override(ContainerStack)
|
||||||
|
def getNextStack(self) -> Optional["GlobalStack"]:
|
||||||
|
return super().getNextStack()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def getLoadingPriority(cls) -> int:
|
def getLoadingPriority(cls) -> int:
|
||||||
return 3
|
return 3
|
||||||
|
@ -250,7 +250,8 @@ def test_getPropertyFallThrough(extruder_stack):
|
|||||||
container_indices = cura.Settings.CuraContainerStack._ContainerIndexes #Cache.
|
container_indices = cura.Settings.CuraContainerStack._ContainerIndexes #Cache.
|
||||||
for type_id, type_name in container_indices.IndexTypeMap.items():
|
for type_id, type_name in container_indices.IndexTypeMap.items():
|
||||||
container = unittest.mock.MagicMock()
|
container = unittest.mock.MagicMock()
|
||||||
container.getProperty = lambda key, property, type_id = type_id: type_id if (key == "layer_height" and property == "value") else None #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 limit_to_extruder
|
||||||
|
container.getProperty = lambda key, property, 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.
|
||||||
container.hasProperty = lambda key, property: key == "layer_height"
|
container.hasProperty = lambda key, property: key == "layer_height"
|
||||||
container.getMetaDataEntry = unittest.mock.MagicMock(return_value = type_name)
|
container.getMetaDataEntry = unittest.mock.MagicMock(return_value = type_name)
|
||||||
mock_layer_heights[type_id] = container
|
mock_layer_heights[type_id] = container
|
||||||
|
@ -350,7 +350,7 @@ def test_getPropertyResolveInInstance(global_stack):
|
|||||||
instance_containers = {}
|
instance_containers = {}
|
||||||
for container_type in container_indices.IndexTypeMap:
|
for container_type in container_indices.IndexTypeMap:
|
||||||
instance_containers[container_type] = unittest.mock.MagicMock() #Sets the resolve and value for bed temperature.
|
instance_containers[container_type] = unittest.mock.MagicMock() #Sets the resolve and value for bed temperature.
|
||||||
instance_containers[container_type].getProperty = lambda key, property: (7.5 if property == "resolve" else (InstanceState.User if property == "state" else 5)) if (key == "material_bed_temperature") else None #7.5 resolve, 5 value.
|
instance_containers[container_type].getProperty = lambda key, property: (7.5 if property == "resolve" else (InstanceState.User if property == "state" else (5 if property != "limit_to_extruder" else "-1"))) if (key == "material_bed_temperature") else None #7.5 resolve, 5 value.
|
||||||
instance_containers[container_type].getMetaDataEntry = unittest.mock.MagicMock(return_value = container_indices.IndexTypeMap[container_type]) #Make queries for the type return the desired type.
|
instance_containers[container_type].getMetaDataEntry = unittest.mock.MagicMock(return_value = container_indices.IndexTypeMap[container_type]) #Make queries for the type return the desired type.
|
||||||
instance_containers[container_indices.Definition].getProperty = lambda key, property: 10 if (key == "material_bed_temperature" and property == "value") else None #Definition only has value.
|
instance_containers[container_indices.Definition].getProperty = lambda key, property: 10 if (key == "material_bed_temperature" and property == "value") else None #Definition only has value.
|
||||||
with unittest.mock.patch("cura.Settings.CuraContainerStack.DefinitionContainer", unittest.mock.MagicMock): #To guard against the type checking.
|
with unittest.mock.patch("cura.Settings.CuraContainerStack.DefinitionContainer", unittest.mock.MagicMock): #To guard against the type checking.
|
||||||
@ -374,7 +374,7 @@ def test_getPropertyResolveInInstance(global_stack):
|
|||||||
# definitions.
|
# definitions.
|
||||||
def test_getPropertyInstancesBeforeResolve(global_stack):
|
def test_getPropertyInstancesBeforeResolve(global_stack):
|
||||||
value = unittest.mock.MagicMock() #Sets just the value.
|
value = unittest.mock.MagicMock() #Sets just the value.
|
||||||
value.getProperty = lambda key, property: (10 if property == "value" else InstanceState.User) if key == "material_bed_temperature" else None
|
value.getProperty = lambda key, property: (10 if property == "value" else (InstanceState.User if property != "limit_to_extruder" else "-1")) if key == "material_bed_temperature" else None
|
||||||
value.getMetaDataEntry = unittest.mock.MagicMock(return_value = "quality")
|
value.getMetaDataEntry = unittest.mock.MagicMock(return_value = "quality")
|
||||||
resolve = unittest.mock.MagicMock() #Sets just the resolve.
|
resolve = unittest.mock.MagicMock() #Sets just the resolve.
|
||||||
resolve.getProperty = lambda key, property: 7.5 if (key == "material_bed_temperature" and property == "resolve") else None
|
resolve.getProperty = lambda key, property: 7.5 if (key == "material_bed_temperature" and property == "resolve") else None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user