mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 14:07:43 +00:00
Run black on BBIM
This commit is contained in:
@@ -681,7 +681,7 @@ def prop_is_roughly_value(prop, value):
|
||||
def the_object_name_has_a_cartesian_point_offset_of_offset(name, offset):
|
||||
offset = replace_variables(offset)
|
||||
obj = the_object_name_exists(name)
|
||||
assert obj.BIMObjectProperties.blender_offset_type == "CARTESIAN_POINT"
|
||||
assert obj.BIMObjectProperties.blender_offset_type == "CARTESIAN_POINT"
|
||||
obj_offset = np.array(tuple(map(float, obj.BIMObjectProperties.cartesian_point_offset.split(","))))
|
||||
offset = np.array(tuple(map(float, offset.split(","))))
|
||||
assert np.allclose(obj_offset, offset)
|
||||
|
||||
@@ -159,13 +159,21 @@ class TestAddBrick:
|
||||
brick.run_assign_brick_reference(element="element", library="library", brick_uri="brick_uri").should_be_called()
|
||||
brick.run_refresh_brick_viewer().should_be_called()
|
||||
subject.add_brick(
|
||||
ifc, brick, element="element", namespace="namespace", brick_class="brick_class", library="library", label="label"
|
||||
ifc,
|
||||
brick,
|
||||
element="element",
|
||||
namespace="namespace",
|
||||
brick_class="brick_class",
|
||||
library="library",
|
||||
label="label",
|
||||
)
|
||||
|
||||
def test_adding_a_plain_brick(self, ifc, brick):
|
||||
brick.add_brick("namespace", "brick_class", "label").should_be_called()
|
||||
brick.run_refresh_brick_viewer().should_be_called()
|
||||
subject.add_brick(ifc, brick, element=None, namespace="namespace", brick_class="brick_class", library=None, label="label")
|
||||
subject.add_brick(
|
||||
ifc, brick, element=None, namespace="namespace", brick_class="brick_class", library=None, label="label"
|
||||
)
|
||||
|
||||
|
||||
class TestAddBrickRelation:
|
||||
@@ -197,24 +205,42 @@ class TestConvertIfcToBrick:
|
||||
|
||||
brick.get_convertable_brick_elements().should_be_called().will_return({"element", "downstream_element"})
|
||||
brick.get_brick_class("element").should_be_called().will_return("element_class")
|
||||
brick.add_brick_from_element("element", "namespace", "element_class").should_be_called().will_return("element_uri")
|
||||
brick.add_brick_from_element("element", "namespace", "element_class").should_be_called().will_return(
|
||||
"element_uri"
|
||||
)
|
||||
brick.get_element_container("element").should_be_called().will_return("space")
|
||||
brick.add_relation("element_uri", "https://brickschema.org/schema/Brick#hasLocation", "space_uri").should_be_called()
|
||||
brick.add_relation(
|
||||
"element_uri", "https://brickschema.org/schema/Brick#hasLocation", "space_uri"
|
||||
).should_be_called()
|
||||
brick.get_element_systems("element").should_be_called().will_return(["system"])
|
||||
brick.add_relation("system_uri", "https://brickschema.org/schema/Brick#hasPart", "element_uri").should_be_called()
|
||||
brick.run_assign_brick_reference(element="element", library="library", brick_uri="element_uri").should_be_called()
|
||||
brick.add_relation(
|
||||
"system_uri", "https://brickschema.org/schema/Brick#hasPart", "element_uri"
|
||||
).should_be_called()
|
||||
brick.run_assign_brick_reference(
|
||||
element="element", library="library", brick_uri="element_uri"
|
||||
).should_be_called()
|
||||
|
||||
brick.get_brick_class("downstream_element").should_be_called().will_return("downstream_element_class")
|
||||
brick.add_brick_from_element("downstream_element", "namespace", "downstream_element_class").should_be_called().will_return("downstream_element_uri")
|
||||
brick.add_brick_from_element(
|
||||
"downstream_element", "namespace", "downstream_element_class"
|
||||
).should_be_called().will_return("downstream_element_uri")
|
||||
brick.get_element_container("downstream_element").should_be_called().will_return("space")
|
||||
brick.add_relation("downstream_element_uri", "https://brickschema.org/schema/Brick#hasLocation", "space_uri").should_be_called()
|
||||
brick.add_relation(
|
||||
"downstream_element_uri", "https://brickschema.org/schema/Brick#hasLocation", "space_uri"
|
||||
).should_be_called()
|
||||
brick.get_element_systems("downstream_element").should_be_called().will_return(["system"])
|
||||
brick.add_relation("system_uri", "https://brickschema.org/schema/Brick#hasPart", "downstream_element_uri").should_be_called()
|
||||
brick.run_assign_brick_reference(element="downstream_element", library="library", brick_uri="downstream_element_uri").should_be_called()
|
||||
brick.add_relation(
|
||||
"system_uri", "https://brickschema.org/schema/Brick#hasPart", "downstream_element_uri"
|
||||
).should_be_called()
|
||||
brick.run_assign_brick_reference(
|
||||
element="downstream_element", library="library", brick_uri="downstream_element_uri"
|
||||
).should_be_called()
|
||||
|
||||
brick.get_element_feeds("element").should_be_called().will_return(["downstream_element"])
|
||||
brick.get_element_feeds("downstream_element").should_be_called().will_return([])
|
||||
brick.add_relation("element_uri", "https://brickschema.org/schema/Brick#feeds", "downstream_element_uri").should_be_called()
|
||||
brick.add_relation(
|
||||
"element_uri", "https://brickschema.org/schema/Brick#feeds", "downstream_element_uri"
|
||||
).should_be_called()
|
||||
brick.run_refresh_brick_viewer().should_be_called()
|
||||
subject.convert_ifc_to_brick(brick, namespace="namespace", library="library")
|
||||
|
||||
|
||||
@@ -195,7 +195,9 @@ class TestSwitchRepresentation:
|
||||
geometry.get_object_data("obj").should_be_called().will_return("current_obj_data")
|
||||
geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation")
|
||||
geometry.get_representation_data("representation").should_be_called().will_return(None)
|
||||
geometry.import_representation("obj", "representation", apply_openings=True).should_be_called().will_return("new_data")
|
||||
geometry.import_representation("obj", "representation", apply_openings=True).should_be_called().will_return(
|
||||
"new_data"
|
||||
)
|
||||
geometry.get_representation_name("representation").should_be_called().will_return("name")
|
||||
geometry.rename_object("new_data", "name").should_be_called()
|
||||
geometry.link("representation", "new_data").should_be_called()
|
||||
@@ -220,7 +222,9 @@ class TestSwitchRepresentation:
|
||||
geometry.get_object_data("obj").should_be_called().will_return("current_obj_data")
|
||||
geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation")
|
||||
geometry.get_representation_data("representation").should_be_called().will_return("existing_data")
|
||||
geometry.import_representation("obj", "representation", apply_openings=True).should_be_called().will_return("new_data")
|
||||
geometry.import_representation("obj", "representation", apply_openings=True).should_be_called().will_return(
|
||||
"new_data"
|
||||
)
|
||||
geometry.get_representation_name("representation").should_be_called().will_return("name")
|
||||
geometry.rename_object("new_data", "name").should_be_called()
|
||||
geometry.link("representation", "new_data").should_be_called()
|
||||
|
||||
@@ -30,7 +30,9 @@ class TestReferenceStructure:
|
||||
class TestDereferenceStructure:
|
||||
def test_run(self, ifc, spatial):
|
||||
spatial.can_reference("structure", "element").should_be_called().will_return(True)
|
||||
ifc.run("spatial.dereference_structure", products=["element"], relating_structure="structure").should_be_called()
|
||||
ifc.run(
|
||||
"spatial.dereference_structure", products=["element"], relating_structure="structure"
|
||||
).should_be_called()
|
||||
subject.dereference_structure(ifc, spatial, structure="structure", element="element")
|
||||
|
||||
|
||||
|
||||
@@ -26,15 +26,15 @@ class TestAssignSceneUnits:
|
||||
unit.get_scene_unit_si_prefix("LENGTHUNIT").should_be_called().will_return("prefix")
|
||||
unit.get_scene_unit_si_prefix("AREAUNIT").should_be_called().will_return("prefix")
|
||||
unit.get_scene_unit_si_prefix("VOLUMEUNIT").should_be_called().will_return("prefix")
|
||||
ifc.run(
|
||||
"unit.add_si_unit", unit_type="LENGTHUNIT", prefix="prefix"
|
||||
).should_be_called().will_return("lengthunit")
|
||||
ifc.run("unit.add_si_unit", unit_type="LENGTHUNIT", prefix="prefix").should_be_called().will_return(
|
||||
"lengthunit"
|
||||
)
|
||||
|
||||
ifc.run("unit.add_si_unit", unit_type="AREAUNIT", prefix="prefix").should_be_called().will_return("areaunit")
|
||||
|
||||
ifc.run(
|
||||
"unit.add_si_unit", unit_type="VOLUMEUNIT", prefix="prefix"
|
||||
).should_be_called().will_return("volumeunit")
|
||||
ifc.run("unit.add_si_unit", unit_type="VOLUMEUNIT", prefix="prefix").should_be_called().will_return(
|
||||
"volumeunit"
|
||||
)
|
||||
|
||||
ifc.run("unit.add_conversion_based_unit", name="degree").should_be_called().will_return("planeangleunit")
|
||||
|
||||
|
||||
@@ -150,4 +150,3 @@ class TestIsMaterialUsedInSets(NewFile):
|
||||
material_set.MaterialLayers = [material_set_item]
|
||||
material_set_item.Material = material
|
||||
assert subject.is_material_used_in_sets(material) is True
|
||||
|
||||
|
||||
@@ -448,7 +448,9 @@ class TestUsingArrays(NewFile):
|
||||
class TestApplyIfcMaterialChanges(NewFile):
|
||||
def get_used_styles(self, obj: bpy.types.Object) -> set[ifcopenshell.entity_instance]:
|
||||
ifc_file = tool.Ifc.get()
|
||||
return {ifc_file.by_id(s.material.BIMStyleProperties.ifc_definition_id) for s in obj.material_slots if s.material}
|
||||
return {
|
||||
ifc_file.by_id(s.material.BIMStyleProperties.ifc_definition_id) for s in obj.material_slots if s.material
|
||||
}
|
||||
|
||||
def get_mesh(self, obj: bpy.types.Object) -> bpy.types.Mesh:
|
||||
mesh = obj.data
|
||||
|
||||
@@ -104,7 +104,14 @@ class TestSetDefaultContext(NewFile):
|
||||
tool.Ifc.set(ifc)
|
||||
ifc.createIfcProject()
|
||||
model = ifcopenshell.api.run("context.add_context", ifc, context_type="Model")
|
||||
body = ifcopenshell.api.run("context.add_context", ifc, parent=model, context_type="Model", context_identifier="Body", target_view="MODEL_VIEW")
|
||||
body = ifcopenshell.api.run(
|
||||
"context.add_context",
|
||||
ifc,
|
||||
parent=model,
|
||||
context_type="Model",
|
||||
context_identifier="Body",
|
||||
target_view="MODEL_VIEW",
|
||||
)
|
||||
subject.set_default_context()
|
||||
assert bpy.context.scene.BIMRootProperties.contexts == str(body.id())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user