mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 15:07:28 -06:00
Start to test other IntentManager functions.
Very rudimentary at the moment, need to split the method into 3, and make a class for the setup. This also uncovered that the currentAvailableIntents doesn't (unless the global stack is missing) retrun any default intents, while currentAvailableIntentCategories does do that. Since it's not clear how we're going to handle that right now, I made a TODO in the code, which of course will have to be fixed before this/these branch/es are merged. part of CURA-6091
This commit is contained in:
parent
6b918dbd1d
commit
810fee37eb
2 changed files with 19 additions and 10 deletions
|
@ -71,9 +71,11 @@ class IntentManager(QObject):
|
||||||
global_stack = application.getGlobalContainerStack()
|
global_stack = application.getGlobalContainerStack()
|
||||||
if global_stack is None:
|
if global_stack is None:
|
||||||
return [("default", "normal")]
|
return [("default", "normal")]
|
||||||
|
# TODO: We now do this (return a default) if the global stack is missing, but not in the code below,
|
||||||
|
# even though there should always be defaults. The problem then is what to do with the quality_types.
|
||||||
|
# Currently _also_ inconsistent with 'currentAvailableIntentCategoreis', which _does_ return default.
|
||||||
quality_groups = application.getQualityManager().getQualityGroups(global_stack)
|
quality_groups = application.getQualityManager().getQualityGroups(global_stack)
|
||||||
available_quality_types = {quality_group.quality_type for quality_group in quality_groups.values() if quality_group.node_for_global is not None}
|
available_quality_types = {quality_group.quality_type for quality_group in quality_groups.values() if quality_group.node_for_global is not None}
|
||||||
# available_quality_types could just be 'quality_group.keys()', except for that the node_for_global may be None
|
|
||||||
|
|
||||||
final_intent_ids = set() #type: Set[str]
|
final_intent_ids = set() #type: Set[str]
|
||||||
current_definition_id = global_stack.definition.getMetaDataEntry("id")
|
current_definition_id = global_stack.definition.getMetaDataEntry("id")
|
||||||
|
|
|
@ -50,6 +50,8 @@ def test_intentCategories(application, intent_manager, container_registry):
|
||||||
|
|
||||||
|
|
||||||
def test_currentAvailableIntents(application, extruder_manager, quality_manager, intent_manager, container_registry, global_stack):
|
def test_currentAvailableIntents(application, extruder_manager, quality_manager, intent_manager, container_registry, global_stack):
|
||||||
|
# This also tests 'currentAvailableIntentCategories' and 'selectIntent' since the methods are so similar
|
||||||
|
|
||||||
mocked_qualitygroup_metadata = {
|
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]
|
||||||
|
@ -88,17 +90,22 @@ def test_currentAvailableIntents(application, extruder_manager, quality_manager,
|
||||||
with patch("cura.CuraApplication.CuraApplication.getInstance", MagicMock(return_value=application)):
|
with patch("cura.CuraApplication.CuraApplication.getInstance", MagicMock(return_value=application)):
|
||||||
with patch("UM.Settings.ContainerRegistry.ContainerRegistry.getInstance", MagicMock(return_value=container_registry)):
|
with patch("UM.Settings.ContainerRegistry.ContainerRegistry.getInstance", MagicMock(return_value=container_registry)):
|
||||||
with patch("cura.Settings.ExtruderManager.ExtruderManager.getInstance", MagicMock(return_value=extruder_manager)):
|
with patch("cura.Settings.ExtruderManager.ExtruderManager.getInstance", MagicMock(return_value=extruder_manager)):
|
||||||
|
|
||||||
intents = intent_manager.currentAvailableIntents()
|
intents = intent_manager.currentAvailableIntents()
|
||||||
assert ("smooth", "normal") in intents
|
assert ("smooth", "normal") in intents
|
||||||
assert ("strong", "abnorm") in intents
|
assert ("strong", "abnorm") in intents
|
||||||
assert len(intents) == 2
|
#assert ("default", "normal") in intents # Pending to-do in 'IntentManager'.
|
||||||
|
#assert ("default", "abnorm") in intents # Pending to-do in 'IntentManager'.
|
||||||
|
assert len(intents) == 2 # Or 4? pending to-do in 'IntentManager'.
|
||||||
|
|
||||||
|
categories = intent_manager.currentAvailableIntentCategories()
|
||||||
|
assert "default" in categories # Currently inconsistent with 'currentAvailableIntents'!
|
||||||
|
assert "smooth" in categories
|
||||||
|
assert "strong" in categories
|
||||||
|
assert len(categories) == 3
|
||||||
|
|
||||||
def test_currentAvailableIntentCategories(application, quality_manager, intent_manager, container_registry):
|
for intent, quality in intents:
|
||||||
# def currentAvailableIntentCategories(self) -> List[str]:
|
intent_manager.selectIntent(intent, quality)
|
||||||
pass
|
assert extruder_stack_a.intent is not None
|
||||||
|
assert extruder_stack_b.intent is not None
|
||||||
|
# ... need MachineManager for this, split up methods anyway -> make into class, see examples others
|
||||||
def test_selectIntent(application, intent_manager, container_registry):
|
|
||||||
# def selectIntent(self, intent_category, quality_type) -> None:
|
|
||||||
pass
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue