Add test for getCurrentQualityGroups if there is no current printer

Contributes to issue CURA-6600.
This commit is contained in:
Ghostkeeper 2019-09-02 13:35:17 +02:00
parent d9e94f5019
commit 10f37c98ff
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276

View file

@ -4,6 +4,8 @@ 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)
@ -54,3 +56,11 @@ def test_alreadyKnownMachineAdded(container_registry):
# The ID is already there, so no machine should be added. # The ID is already there, so no machine should be added.
container_tree._machineAdded(mocked_definition_container) container_tree._machineAdded(mocked_definition_container)
assert len(container_tree.machines) == 2 assert len(container_tree.machines) == 2
def test_getCurrentQualityGroupsNoGlobalStack(container_registry):
with patch("UM.Settings.ContainerRegistry.ContainerRegistry.getInstance", MagicMock(return_value = container_registry)):
with patch("cura.CuraApplication.CuraApplication.getInstance", MagicMock(return_value = MagicMock(getGlobalContainerStack = MagicMock(return_value = None)))):
container_tree = ContainerTree()
result = container_tree.getCurrentQualityGroups()
assert len(result) == 0