#2094. You can now add material sets independently of IFC objects in the material manager

This commit is contained in:
Dion Moult
2022-03-19 22:12:58 +11:00
parent fdd03d7294
commit a43fae68b6
9 changed files with 170 additions and 52 deletions
+63 -5
View File
@@ -17,7 +17,7 @@
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
import blenderbim.core.material as subject
from test.core.bootstrap import ifc, material
from test.core.bootstrap import ifc, material, style
class TestUnlinkMaterial:
@@ -26,12 +26,70 @@ class TestUnlinkMaterial:
subject.unlink_material(ifc, obj="obj")
class TestAddDefaultMaterial:
def test_run(self, ifc, material):
class TestAddMaterial:
def test_add_a_default_material(self, ifc, material, style):
material.add_default_material_object().should_be_called().will_return("obj")
ifc.run("material.add_material", name="Default").should_be_called().will_return("material")
material.get_name("obj").should_be_called().will_return("name")
ifc.run("material.add_material", name="name").should_be_called().will_return("material")
ifc.link("material", "obj").should_be_called()
assert subject.add_default_material(ifc, material) == "obj"
style.get_style("obj").should_be_called().will_return(None)
material.is_editing_materials().should_be_called().will_return(False)
assert subject.add_material(ifc, material, style) == "material"
def test_add_a_material_to_a_blender_material_object(self, ifc, material, style):
material.get_name("obj").should_be_called().will_return("name")
ifc.run("material.add_material", name="name").should_be_called().will_return("material")
ifc.link("material", "obj").should_be_called()
style.get_style("obj").should_be_called().will_return(None)
material.is_editing_materials().should_be_called().will_return(False)
assert subject.add_material(ifc, material, style, obj="obj") == "material"
def test_reloading_imported_materials_if_you_are_editing_scene_materials(self, ifc, material, style):
material.get_name("obj").should_be_called().will_return("name")
ifc.run("material.add_material", name="name").should_be_called().will_return("material")
ifc.link("material", "obj").should_be_called()
style.get_style("obj").should_be_called().will_return(None)
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()
assert subject.add_material(ifc, material, style, obj="obj") == "material"
def test_add_a_style_to_the_material_if_the_object_also_has_an_attached_style(self, ifc, material, style):
material.get_name("obj").should_be_called().will_return("name")
ifc.run("material.add_material", name="name").should_be_called().will_return("material")
ifc.link("material", "obj").should_be_called()
style.get_style("obj").should_be_called().will_return("style")
style.get_context("obj").should_be_called().will_return("context")
ifc.run("style.assign_material_style", material="material", style="style", context="context").should_be_called()
material.is_editing_materials().should_be_called().will_return(False)
assert subject.add_material(ifc, material, style, obj="obj") == "material"
def test_not_adding_a_style_if_there_is_no_style_context_available(self, ifc, material, style):
material.get_name("obj").should_be_called().will_return("name")
ifc.run("material.add_material", name="name").should_be_called().will_return("material")
ifc.link("material", "obj").should_be_called()
style.get_style("obj").should_be_called().will_return("style")
style.get_context("obj").should_be_called().will_return(None)
material.is_editing_materials().should_be_called().will_return(False)
assert subject.add_material(ifc, material, style, obj="obj") == "material"
class TestAddMaterialSet:
def test_adding_a_material_set(self, ifc, material):
ifc.run("material.add_material_set", name="Unnamed", set_type="set_type").should_be_called().will_return(
"material"
)
material.is_editing_materials().should_be_called().will_return(False)
assert subject.add_material_set(ifc, material, set_type="set_type") == "material"
def test_adding_a_material_set_and_reloading_imported_materials(self, ifc, material):
ifc.run("material.add_material_set", name="Unnamed", set_type="set_type").should_be_called().will_return(
"material"
)
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()
assert subject.add_material_set(ifc, material, set_type="set_type") == "material"
class TestLoadMaterials: