diff options
author | Remco Burema <r.burema@ultimaker.com> | 2019-06-21 15:37:10 +0300 |
---|---|---|
committer | Remco Burema <r.burema@ultimaker.com> | 2019-06-21 15:37:10 +0300 |
commit | 0f9de9935e8ce17febc0dc180a1be2ff416ca3ad (patch) | |
tree | d4a3705930c4a3d4e8dc7f631dc4a41ac8b208b6 /tests/TestIntentManager.py | |
parent | f339686c499de00a8cd17e7a10d0a7b221dfea8f (diff) |
Add unit-test for .intentCategories
Part of CURA-6091.
Diffstat (limited to 'tests/TestIntentManager.py')
-rw-r--r-- | tests/TestIntentManager.py | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/tests/TestIntentManager.py b/tests/TestIntentManager.py index a30de04565..519fa49994 100644 --- a/tests/TestIntentManager.py +++ b/tests/TestIntentManager.py @@ -12,9 +12,16 @@ def global_stack(): return MagicMock(name="Global Stack") @pytest.fixture() -def container_registry() -> ContainerRegistry: - return MagicMock(name = "ContainerRegistry") +def container_registry(application, global_stack) -> ContainerRegistry: + result = MagicMock() + mocked_metadata = [{"id": "um3_aa4_pla_smooth", "GUID": "abcxyz", "definition": "ultimaker3", "variant": "AA 0.4", "material_id": "generic_pla", "intent_category": "smooth"}, + {"id": "um3_aa4_pla_strong", "GUID": "defqrs", "definition": "ultimaker3", "variant": "AA 0.4", "material_id": "generic_pla", "intent_category": "strong"}] + result.findContainersMetadata = MagicMock(return_value = mocked_metadata) + result.findContainerStacks = MagicMock(return_value = [global_stack]) + application.getContainerRegistry = MagicMock(return_value = result) + + return result @pytest.fixture() def extruder_manager(application, container_registry) -> ExtruderManager: @@ -32,7 +39,28 @@ def extruder_manager(application, container_registry) -> ExtruderManager: def machine_manager(application, extruder_manager, container_registry, global_stack) -> MachineManager: application.getExtruderManager = MagicMock(return_value = extruder_manager) application.getGlobalContainerStack = MagicMock(return_value = global_stack) - with patch("cura.Settings.CuraContainerRegistry.CuraContainerRegistry.getInstance", MagicMock(return_value=container_registry)): + with patch("UM.Settings.ContainerRegistry.ContainerRegistry.getInstance", MagicMock(return_value=container_registry)): manager = MachineManager(application) return manager + +# TODO: maybe put some definitions above in common file because they copy the ones in TestMachineManager (also there). + +@pytest.fixture() +def intent_manager(application, extruder_manager, machine_manager, container_registry, global_stack) -> IntentManager: + application.getExtruderManager = MagicMock(return_value = extruder_manager) + application.getGlobalContainerStack = MagicMock(return_value = global_stack) + application.getMachineManager = MagicMock(return_value = machine_manager) + with patch("cura.CuraApplication.CuraApplication.getInstance", MagicMock(return_value=application)): + with patch("UM.Settings.ContainerRegistry.ContainerRegistry.getInstance", MagicMock(return_value=container_registry)): + manager = IntentManager() + + return manager + +def test_intentCategories(application, intent_manager, container_registry): + with patch("cura.CuraApplication.CuraApplication.getInstance", MagicMock(return_value=application)): + with patch("UM.Settings.ContainerRegistry.ContainerRegistry.getInstance", MagicMock(return_value=container_registry)): + categories = intent_manager.intentCategories("ultimaker3", "AA 0.4", "generic_pla") # type:List[str] + assert "default" in categories, "default should always be in categories" + assert "strong" in categories, "strong should be in categories" + assert "smooth" in categories, "smooth should be in categories" |