示例#1
0
def test_getQualityChangesGroup(quality_mocked_application):
    manager = QualityManager(quality_mocked_application)
    manager.initialize()

    assert "herp" in [
        qcg.name for qcg in manager.getQualityChangesGroups(mocked_stack)
    ]
示例#2
0
def test_createQualityChanges(quality_mocked_application):
    manager = QualityManager(quality_mocked_application)
    mocked_quality_changes = MagicMock()
    manager._createQualityChanges = MagicMock(return_value = mocked_quality_changes)
    manager.initialize()
    container_manager = MagicMock()

    manager._container_registry.addContainer = MagicMock()  # Side effect we want to check.
    with patch("cura.Settings.ContainerManager.ContainerManager.getInstance", container_manager):
        manager.createQualityChanges("derp")
        assert manager._container_registry.addContainer.called_once_with(mocked_quality_changes)
示例#3
0
def test_renameQualityChangesGroup(quality_mocked_application):
    manager = QualityManager(quality_mocked_application)
    manager.initialize()

    mocked_container = MagicMock()

    quality_changes_group = QualityChangesGroup("zomg", "beep")
    quality_changes_group.getAllNodes = MagicMock(return_value = [mocked_container])

    # We need to check for "uniqueName" instead of "NEWRANDOMNAMEYAY" because the mocked registry always returns
    # "uniqueName" when attempting to generate an unique name.
    assert manager.renameQualityChangesGroup(quality_changes_group, "NEWRANDOMNAMEYAY") == "uniqueName"
    assert mocked_container.setName.called_once_with("uniqueName")
示例#4
0
def test_duplicateQualityChangesQualityOnly(quality_mocked_application):
    manager = QualityManager(quality_mocked_application)
    manager.initialize()
    mocked_quality = MagicMock()
    quality_group = MagicMock()
    quality_group.getAllNodes = MagicMock(return_value = mocked_quality)
    mocked_quality_changes = MagicMock()

    # Isolate what we want to test (in this case, we're not interested if createQualityChanges does it's job!)
    manager._createQualityChanges = MagicMock(return_value = mocked_quality_changes)
    manager._container_registry.addContainer = MagicMock()  # Side effect we want to check.

    manager.duplicateQualityChanges("zomg", {"quality_group": quality_group, "quality_changes_group": None})
    assert manager._container_registry.addContainer.called_once_with(mocked_quality_changes)
示例#5
0
def test_duplicateQualityChanges(quality_mocked_application):
    manager = QualityManager(quality_mocked_application)
    manager.initialize()
    mocked_quality = MagicMock()
    quality_group = MagicMock()
    quality_group.getAllNodes = MagicMock(return_value = mocked_quality)
    quality_changes_group = MagicMock()
    mocked_quality_changes = MagicMock()
    quality_changes_group.getAllNodes = MagicMock(return_value=[mocked_quality_changes])
    mocked_quality_changes.duplicate = MagicMock(return_value = mocked_quality_changes)

    manager._container_registry.addContainer = MagicMock()  # Side effect we want to check.

    manager.duplicateQualityChanges("zomg", {"quality_group": quality_group, "quality_changes_group": quality_changes_group})
    assert manager._container_registry.addContainer.called_once_with(mocked_quality_changes)
示例#6
0
def test_getDefaultQualityType(quality_mocked_application):
    manager = QualityManager(quality_mocked_application)
    manager.initialize()
    mocked_stack = MagicMock()
    mocked_stack.definition.getMetaDataEntry = MagicMock(return_value="normal")
    assert manager.getDefaultQualityType(mocked_stack).quality_type == "normal"
示例#7
0
def test_getQualityGroups(quality_mocked_application):
    manager = QualityManager(quality_mocked_application)
    manager.initialize()

    assert "normal" in manager.getQualityGroups(mocked_stack)