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:
Remco Burema 2019-06-28 12:10:39 +02:00
parent 6b918dbd1d
commit 810fee37eb
2 changed files with 19 additions and 10 deletions

View file

@ -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):
# This also tests 'currentAvailableIntentCategories' and 'selectIntent' since the methods are so similar
mocked_qualitygroup_metadata = {
"normal": QualityGroup("um3_aa4_pla_normal", "normal"),
"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("UM.Settings.ContainerRegistry.ContainerRegistry.getInstance", MagicMock(return_value=container_registry)):
with patch("cura.Settings.ExtruderManager.ExtruderManager.getInstance", MagicMock(return_value=extruder_manager)):
intents = intent_manager.currentAvailableIntents()
assert ("smooth", "normal") 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):
# def currentAvailableIntentCategories(self) -> List[str]:
pass
def test_selectIntent(application, intent_manager, container_registry):
# def selectIntent(self, intent_category, quality_type) -> None:
pass
for intent, quality in intents:
intent_manager.selectIntent(intent, quality)
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