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
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"
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"
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.
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"
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
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"
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
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
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"
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
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"
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
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"
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