示例#1
0
def test_getMaterialNodeByTypeMachineHasNoMaterials(application):
    with patch("UM.Application.Application.getInstance", MagicMock(return_value=application)):
        manager = MaterialManager(mocked_registry)
    manager.initialize()

    mocked_stack = MagicMock()
    assert manager.getMaterialNodeByType(mocked_stack, "0", "nozzle", "", "") is None
示例#2
0
def test_getMaterialGroupListByGUID(application):
    with patch("UM.Application.Application.getInstance", MagicMock(return_value=application)):
        manager = MaterialManager(mocked_registry)
    manager.initialize()

    assert manager.getMaterialGroupListByGUID("TEST!")[0].name == "test"
    assert manager.getMaterialGroupListByGUID("TEST2!")[0].name == "base_material"
示例#3
0
    def test_happyFlow(self, application):
        with patch("UM.Application.Application.getInstance",
                   MagicMock(return_value=application)):
            manager = MaterialManager(mocked_registry)
        manager.initialize()

        assert manager.getFallbackMaterialIdByMaterialType("pla") == "test"
示例#4
0
    def test_wrongDiameter(self, application):
        with patch("UM.Application.Application.getInstance", MagicMock(return_value=application)):
            manager = MaterialManager(mocked_registry)
        manager.initialize()

        available_materials = manager.getAvailableMaterials(mocked_definition, None, None, 200)
        assert available_materials == {} # Nothing found.
示例#5
0
def test_initialize(application):
    # Just test if the simple loading works
    with patch("UM.Application.Application.getInstance", MagicMock(return_value=application)):
        manager = MaterialManager(mocked_registry)
    manager.initialize()
    # Double check that we actually got some material nodes
    assert manager.getMaterialGroup("base_material").name == "base_material"
    assert manager.getMaterialGroup("test").name == "test"
示例#6
0
 def test_excludedMaterials(self, application):
     with patch("UM.Application.Application.getInstance", MagicMock(return_value=application)):
         manager = MaterialManager(mocked_registry)
     manager.initialize()
     with patch.object(mocked_definition, "getMetaDataEntry", MagicMock(return_value = ["test"])):
         available_materials = manager.getAvailableMaterials(mocked_definition, None, None, 3)
     assert "base_material" in available_materials
     assert "test" not in available_materials
示例#7
0
def test_initialize(application):
    # Just test if the simple loading works
    with patch("UM.Application.Application.getInstance", MagicMock(return_value=application)):
        manager = MaterialManager(mocked_registry)
    manager.initialize()
    # Double check that we actually got some material nodes
    assert manager.getMaterialGroup("base_material").name == "base_material"
    assert manager.getMaterialGroup("test").name == "test"
示例#8
0
def test_getRootMaterialIDforDiameter(application):
    with patch("UM.Application.Application.getInstance",
               MagicMock(return_value=application)):
        manager = MaterialManager(mocked_registry)
    manager.initialize()

    assert manager.getRootMaterialIDForDiameter("base_material",
                                                "3") == "base_material"
示例#9
0
def test_getAvailableMaterials(application):
    with patch("UM.Application.Application.getInstance", MagicMock(return_value=application)):
        manager = MaterialManager(mocked_registry)
    manager.initialize()

    available_materials = manager.getAvailableMaterials(mocked_definition, None, None, 3)

    assert "base_material" in available_materials
    assert "test" in available_materials
示例#10
0
def test_getMaterialNodeByTypeMachineHasMaterialsButNoMaterialFound(application):
    with patch("UM.Application.Application.getInstance", MagicMock(return_value=application)):
        manager = MaterialManager(mocked_registry)
    manager.initialize()

    mocked_stack = MagicMock()
    mocked_stack.definition.getMetaDataEntry = MagicMock(return_value = True)  # For the "has_materials" metadata

    assert manager.getMaterialNodeByType(mocked_stack, "0", "nozzle", "", "") is None
示例#11
0
def test_getMaterialNode(application):
    with patch("UM.Application.Application.getInstance",
               MagicMock(return_value=application)):
        manager = MaterialManager(mocked_registry)
    manager.initialize()

    assert manager.getMaterialNode(
        "fdmmachine", None, None, 3,
        "base_material").getMetaDataEntry("id") == "test"
示例#12
0
    def test_happy(self, application):
        with patch("UM.Application.Application.getInstance", MagicMock(return_value=application)):
            manager = MaterialManager(mocked_registry)
        manager.initialize()

        available_materials = manager.getAvailableMaterials(mocked_definition, None, None, 3)

        assert "base_material" in available_materials
        assert "test" in available_materials
示例#13
0
def test_getAllMaterialGroups(application):
    with patch("UM.Application.Application.getInstance", MagicMock(return_value=application)):
        manager = MaterialManager(mocked_registry)
    manager.initialize()

    material_groups = manager.getAllMaterialGroups()

    assert "base_material" in material_groups
    assert "test" in material_groups
    assert material_groups["base_material"].name == "base_material"
    assert material_groups["test"].name == "test"
示例#14
0
def test_getAvailableMaterialsForMachineExtruder(application):
    with patch("UM.Application.Application.getInstance", MagicMock(return_value=application)):
        manager = MaterialManager(mocked_registry)
    manager.initialize()

    mocked_machine = MagicMock()
    mocked_machine.getBuildplateName = MagicMock(return_value = "build_plate")
    mocked_machine.definition = mocked_definition
    mocked_extruder_stack = MagicMock()
    mocked_extruder_stack.variant.getId = MagicMock(return_value = "test")
    mocked_extruder_stack.getApproximateMaterialDiameter = MagicMock(return_value = 2.85)

    available_materials = manager.getAvailableMaterialsForMachineExtruder(mocked_machine, mocked_extruder_stack)
    assert "base_material" in available_materials
    assert "test" in available_materials
示例#15
0
def test_getAvailableMaterialsForMachineExtruder(application):
    with patch("UM.Application.Application.getInstance", MagicMock(return_value=application)):
        manager = MaterialManager(mocked_registry)
    manager.initialize()

    mocked_machine = MagicMock()
    mocked_machine.getBuildplateName = MagicMock(return_value = "build_plate")
    mocked_machine.definition = mocked_definition
    mocked_extruder_stack = MagicMock()
    mocked_extruder_stack.variant.getId = MagicMock(return_value = "test")
    mocked_extruder_stack.getApproximateMaterialDiameter = MagicMock(return_value = 2.85)

    available_materials = manager.getAvailableMaterialsForMachineExtruder(mocked_machine, mocked_extruder_stack)
    assert "base_material" in available_materials
    assert "test" in available_materials
示例#16
0
def test_getMaterialNode(application):
    with patch("UM.Application.Application.getInstance", MagicMock(return_value=application)):
        manager = MaterialManager(mocked_registry)
    manager.initialize()

    assert manager.getMaterialNode("fdmmachine", None, None, 3, "base_material").getMetaDataEntry("id") == "test"
示例#17
0
 def test_unknownMaterial(self, application):
     with patch("UM.Application.Application.getInstance",
                MagicMock(return_value=application)):
         manager = MaterialManager(mocked_registry)
     manager.initialize()
     assert manager.getFallbackMaterialIdByMaterialType("OMGZOMG") is None