mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 22:33:33 +00:00
ifc.unlink fixes after 3df75e9af
Also some changes related to #4843 add
This commit is contained in:
@@ -87,46 +87,23 @@ class TestAddMaterialSet:
|
||||
|
||||
|
||||
class TestRemoveMaterial:
|
||||
def test_removing_a_material(self, ifc, material, style):
|
||||
def test_removing_a_material(self, ifc, material):
|
||||
material.is_material_used_in_sets("material").should_be_called().will_return(False)
|
||||
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")
|
||||
subject.remove_material(ifc, material, material="material")
|
||||
|
||||
def test_removing_a_material_and_reloading_imported_materials(self, ifc, material, style):
|
||||
def test_removing_a_material_and_reloading_imported_materials(self, ifc, material):
|
||||
material.is_material_used_in_sets("material").should_be_called().will_return(False)
|
||||
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")
|
||||
subject.remove_material(ifc, material, material="material")
|
||||
|
||||
def test_removing_a_material_object_if_it_has_no_style(self, ifc, material, style):
|
||||
material.is_material_used_in_sets("material").should_be_called().will_return(False)
|
||||
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):
|
||||
material.is_material_used_in_sets("material").should_be_called().will_return(False)
|
||||
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")
|
||||
|
||||
def test_not_removing_a_material_if_it_is_used_in_a_material_set(self, ifc, material, style):
|
||||
def test_not_removing_a_material_if_it_is_used_in_a_material_set(self, ifc, material):
|
||||
material.is_material_used_in_sets("material").should_be_called().will_return(True)
|
||||
subject.remove_material(ifc, material, style, material="material")
|
||||
subject.remove_material(ifc, material, material="material")
|
||||
|
||||
|
||||
class TestRemoveMaterialSet:
|
||||
|
||||
@@ -53,32 +53,23 @@ class TestAddStyle:
|
||||
|
||||
|
||||
class TestRemoveStyle:
|
||||
def test_removing_a_style(self, ifc, material, style):
|
||||
def test_removing_a_style(self, ifc, style):
|
||||
ifc.get_object("style").should_be_called().will_return("obj")
|
||||
ifc.unlink(obj="obj", element="style").should_be_called()
|
||||
ifc.unlink(element="style").should_be_called()
|
||||
ifc.run("style.remove_style", style="style").should_be_called()
|
||||
ifc.get_entity("obj").should_be_called().will_return("material")
|
||||
style.delete_object("obj").should_be_called()
|
||||
style.is_editing_styles().should_be_called().will_return(False)
|
||||
subject.remove_style(ifc, material, style, style="style")
|
||||
subject.remove_style(ifc, style, style="style")
|
||||
|
||||
def test_removing_a_style_and_reloading_imported_styles(self, ifc, material, style):
|
||||
def test_removing_a_style_and_reloading_imported_styles(self, ifc, style):
|
||||
ifc.get_object("style").should_be_called().will_return("obj")
|
||||
ifc.unlink(obj="obj", element="style").should_be_called()
|
||||
ifc.unlink(element="style").should_be_called()
|
||||
ifc.run("style.remove_style", style="style").should_be_called()
|
||||
ifc.get_entity("obj").should_be_called().will_return("material")
|
||||
style.delete_object("obj").should_be_called()
|
||||
style.is_editing_styles().should_be_called().will_return(True)
|
||||
style.get_active_style_type().should_be_called().will_return("style_type")
|
||||
style.import_presentation_styles("style_type").should_be_called()
|
||||
subject.remove_style(ifc, material, style, style="style")
|
||||
|
||||
def test_removing_an_object_if_it_is_not_still_used_for_a_material(self, ifc, material, style):
|
||||
ifc.get_object("style").should_be_called().will_return("obj")
|
||||
ifc.unlink(obj="obj", element="style").should_be_called()
|
||||
ifc.run("style.remove_style", style="style").should_be_called()
|
||||
ifc.get_entity("obj").should_be_called().will_return(None)
|
||||
material.delete_object("obj").should_be_called()
|
||||
style.is_editing_styles().should_be_called().will_return(False)
|
||||
subject.remove_style(ifc, material, style, style="style")
|
||||
subject.remove_style(ifc, style, style="style")
|
||||
|
||||
|
||||
class TestUpdateStyleColours:
|
||||
|
||||
@@ -47,6 +47,6 @@ class TestPurgeUnusedTypes:
|
||||
type.get_type_occurrences("element_type").should_be_called().will_return([])
|
||||
ifc.run("root.remove_product", product="element_type").should_be_called()
|
||||
ifc.get_object("element_type").should_be_called().will_return("obj")
|
||||
ifc.unlink(obj="obj").should_be_called()
|
||||
ifc.unlink(element="element_type").should_be_called()
|
||||
type.remove_object("obj").should_be_called()
|
||||
subject.purge_unused_types(ifc, type)
|
||||
|
||||
Reference in New Issue
Block a user