mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 06:33:55 -06:00
Add test for preferred material with the happy flow
The exact preferred material is available. Pick that.
This commit is contained in:
parent
e5c0812acc
commit
a117e937b9
4 changed files with 29 additions and 1 deletions
|
@ -1,3 +1,6 @@
|
|||
# Copyright (c) 2019 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from unittest.mock import patch, MagicMock
|
||||
import pytest
|
||||
from UM.Settings.DefinitionContainer import DefinitionContainer
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
# Copyright (c) 2019 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from unittest.mock import patch, MagicMock
|
||||
import pytest
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
# Copyright (c) 2019 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from unittest.mock import patch, MagicMock
|
||||
import pytest
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
# Copyright (c) 2019 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from unittest.mock import patch, MagicMock
|
||||
import pytest
|
||||
|
||||
|
@ -113,3 +116,19 @@ def test_materialAdded_update(container_registry, machine_node, metadata, change
|
|||
for key in changed_material_list:
|
||||
assert original_material_nodes[key] != variant_node.materials[key]
|
||||
|
||||
def test_preferredMaterialExactMatch():
|
||||
container_registry = MagicMock(
|
||||
findContainersMetadata = MagicMock(return_value = [{"name": "test variant name"}])
|
||||
)
|
||||
machine_node = MagicMock(preferred_material = "preferred_material_base_file")
|
||||
|
||||
# Construct our own variant node with certain materials available.
|
||||
with patch("UM.Settings.ContainerRegistry.ContainerRegistry.getInstance", MagicMock(return_value = container_registry)):
|
||||
with patch("cura.Machines.VariantNode.VariantNode._loadAll", MagicMock()):
|
||||
variant_node = VariantNode("test_variant", machine_node)
|
||||
variant_node.materials = {
|
||||
"some_different_material": MagicMock(getMetaDataEntry = lambda x: 3),
|
||||
"preferred_material_base_file": MagicMock(getMetaDataEntry = lambda x: 3) # Exact match.
|
||||
}
|
||||
|
||||
assert variant_node.preferredMaterial(approximate_diameter = 3) == variant_node.materials["preferred_material_base_file"], "It should match exactly on this one since it's the preferred material."
|
Loading…
Add table
Add a link
Reference in a new issue