Remove _added functions for nodes that can't be added during runtime

Among the machines, variants, materials, qualities and intents, only machines and materials can ever be added during runtime. For the rest, we don't need to listen to these signals.

Contributes to issue CURA-6600.
This commit is contained in:
Ghostkeeper 2019-08-16 16:28:42 +02:00
parent 97e77994a1
commit 80baeb9873
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276
6 changed files with 7 additions and 188 deletions

View file

@ -4,14 +4,6 @@ import pytest
from UM.Settings.Interfaces import ContainerInterface
from cura.Machines.MachineNode import MachineNode
machine_node_variant_added_test_data = [({"type": "Not a variant!"}, ["Variant One", "Variant Two"]), # Wrong type
({"type": "variant", "name": "Variant One"}, ["Variant One", "Variant Two"]), # Name already added
({"type": "variant", "name": "Variant Three", "hardware_type": "Not a nozzle"}, ["Variant One", "Variant Two"]), # Wrong hardware type
({"type": "variant", "name": "Variant Three", "hardware_type": "nozzle", "definition": "machine_3"}, ["Variant One", "Variant Two"]), # Wrong definition ID
({"type": "variant", "name": "Variant Three", "hardware_type": "nozzle", "definition": "machine_1"}, ["Variant One", "Variant Two", "Variant Three"])] # Yay! It's finally added
metadata_dict = {}
@ -44,18 +36,4 @@ def test_machineNodeInit(container_registry):
# As variants get stored by name, we want to check if those get added.
assert "Variant One" in machine_node.variants
assert "Variant Two" in machine_node.variants
assert len(machine_node.variants) == 2 # And ensure that *only* those two got added.
@pytest.mark.parametrize("metadata,variant_result_list", machine_node_variant_added_test_data)
def test_machineNodeVariantAdded(container_registry, metadata, variant_result_list):
machine_node = createMachineNode("machine_1", container_registry)
with patch("cura.Machines.MachineNode.VariantNode"): # We're not testing the variant node here, so patch it out.
with patch.dict(metadata_dict, metadata):
mocked_container = createMockedInstanceContainer()
machine_node._variantAdded(mocked_container)
assert len(variant_result_list) == len(machine_node.variants)
for name in variant_result_list:
assert name in machine_node.variants
assert len(machine_node.variants) == 2 # And ensure that *only* those two got added.