mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +00:00
#2094. Deleting materials now also deletes Blender material if not used for a style
This commit is contained in:
@@ -92,6 +92,50 @@ class TestAddMaterialSet:
|
||||
assert subject.add_material_set(ifc, material, set_type="set_type") == "material"
|
||||
|
||||
|
||||
class TestRemoveMaterial:
|
||||
def test_removing_a_material(self, ifc, material, style):
|
||||
ifc.get_object("material").should_be_called().will_return(None)
|
||||
ifc.unlink(element="material").should_be_called()
|
||||
ifc.run("material.remove_material", material="material").should_be_called()
|
||||
material.is_editing_materials().should_be_called().will_return(False)
|
||||
subject.remove_material(ifc, material, style, material="material")
|
||||
|
||||
def test_removing_a_material_and_reloading_imported_materials(self, ifc, material, style):
|
||||
ifc.get_object("material").should_be_called().will_return(None)
|
||||
ifc.unlink(element="material").should_be_called()
|
||||
ifc.run("material.remove_material", material="material").should_be_called()
|
||||
material.is_editing_materials().should_be_called().will_return(True)
|
||||
material.get_active_material_type().should_be_called().will_return("material_type")
|
||||
material.import_material_definitions("material_type").should_be_called()
|
||||
subject.remove_material(ifc, material, style, material="material")
|
||||
|
||||
def test_removing_a_material_object_if_it_has_no_style(self, ifc, material, style):
|
||||
ifc.get_object("material").should_be_called().will_return("obj")
|
||||
ifc.unlink(element="material").should_be_called()
|
||||
ifc.run("material.remove_material", material="material").should_be_called()
|
||||
style.get_style("obj").should_be_called().will_return(None)
|
||||
material.delete_object("obj").should_be_called()
|
||||
material.is_editing_materials().should_be_called().will_return(False)
|
||||
subject.remove_material(ifc, material, style, material="material")
|
||||
|
||||
def test_preserving_a_material_object_if_it_is_still_used_as_a_style(self, ifc, material, style):
|
||||
ifc.get_object("material").should_be_called().will_return("obj")
|
||||
ifc.unlink(element="material").should_be_called()
|
||||
ifc.run("material.remove_material", material="material").should_be_called()
|
||||
style.get_style("obj").should_be_called().will_return("style")
|
||||
material.is_editing_materials().should_be_called().will_return(False)
|
||||
subject.remove_material(ifc, material, style, material="material")
|
||||
|
||||
|
||||
class TestRemoveMaterialSet:
|
||||
def test_run(self, ifc, material):
|
||||
ifc.run("material.remove_material_set", material="material").should_be_called()
|
||||
material.is_editing_materials().should_be_called().will_return(True)
|
||||
material.get_active_material_type().should_be_called().will_return("material_type")
|
||||
material.import_material_definitions("material_type").should_be_called()
|
||||
subject.remove_material_set(ifc, material, material="material")
|
||||
|
||||
|
||||
class TestLoadMaterials:
|
||||
def test_run(self, material):
|
||||
material.import_material_definitions("material_type").should_be_called()
|
||||
|
||||
Reference in New Issue
Block a user