bim.add_material_set to ensure adding valid material sets

This commit is contained in:
Andrej730
2024-09-02 18:33:10 +05:00
parent 90e9c21320
commit c6e8d2a585
7 changed files with 91 additions and 1 deletions
+2
View File
@@ -49,6 +49,7 @@ class TestAddMaterialSet:
ifc.run("material.add_material_set", name="Unnamed", set_type="set_type").should_be_called().will_return(
"material"
)
material.ensure_new_material_set_is_valid("material").should_be_called()
material.is_editing_materials().should_be_called().will_return(False)
assert subject.add_material_set(ifc, material, set_type="set_type") == "material"
@@ -56,6 +57,7 @@ class TestAddMaterialSet:
ifc.run("material.add_material_set", name="Unnamed", set_type="set_type").should_be_called().will_return(
"material"
)
material.ensure_new_material_set_is_valid("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()
+33
View File
@@ -150,3 +150,36 @@ class TestIsMaterialUsedInSets(NewFile):
material_set.MaterialLayers = [material_set_item]
material_set_item.Material = material
assert subject.is_material_used_in_sets(material) is True
class TestEnsureNewMaterialSetIsValid(NewFile):
def test_material_constituent_set(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
material_set = ifc.create_entity("IfcMaterialConstituentSet")
subject.ensure_new_material_set_is_valid(material_set)
assert len(constituents := material_set.MaterialConstituents) == 1
assert constituents[0].Material
def test_material_layer_set(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
material_set = ifc.create_entity("IfcMaterialLayerSet")
subject.ensure_new_material_set_is_valid(material_set)
assert len(layers := material_set.MaterialLayers) == 1
assert layers[0].Material
def test_material_profile_set(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
material_set = ifc.create_entity("IfcMaterialProfileSet")
subject.ensure_new_material_set_is_valid(material_set)
assert len(profiles := material_set.MaterialProfiles) == 1
assert profiles[0].Profile
def test_material_list(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
material_set = ifc.create_entity("IfcMaterialList")
subject.ensure_new_material_set_is_valid(material_set)
assert len(material_set.Materials) == 1