mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 02:19:04 +08:00
Add test for preferred material matching on submaterials
Done during Turbo Testing and Tooling.
This commit is contained in:
parent
a117e937b9
commit
54fcb38fe6
@ -116,6 +116,8 @@ def test_materialAdded_update(container_registry, machine_node, metadata, change
|
|||||||
for key in changed_material_list:
|
for key in changed_material_list:
|
||||||
assert original_material_nodes[key] != variant_node.materials[key]
|
assert original_material_nodes[key] != variant_node.materials[key]
|
||||||
|
|
||||||
|
## Tests the preferred material when the exact base file is available in the
|
||||||
|
# materials list for this node.
|
||||||
def test_preferredMaterialExactMatch():
|
def test_preferredMaterialExactMatch():
|
||||||
container_registry = MagicMock(
|
container_registry = MagicMock(
|
||||||
findContainersMetadata = MagicMock(return_value = [{"name": "test variant name"}])
|
findContainersMetadata = MagicMock(return_value = [{"name": "test variant name"}])
|
||||||
@ -131,4 +133,23 @@ def test_preferredMaterialExactMatch():
|
|||||||
"preferred_material_base_file": MagicMock(getMetaDataEntry = lambda x: 3) # Exact match.
|
"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."
|
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."
|
||||||
|
|
||||||
|
## Tests the preferred material when a submaterial is available in the
|
||||||
|
# materials list for this node.
|
||||||
|
def test_preferredMaterialSubmaterial():
|
||||||
|
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_aa04": MagicMock(getMetaDataEntry = lambda x: 3) # This is a submaterial of the preferred material.
|
||||||
|
}
|
||||||
|
|
||||||
|
assert variant_node.preferredMaterial(approximate_diameter = 3) == variant_node.materials["preferred_material_base_file_aa04"], "It should match exactly on this one since it's the preferred material."
|
Loading…
x
Reference in New Issue
Block a user