mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-11 22:31:55 +00:00
Minor cleanup to Brick code after failed attempt to detect feed relationships.
This commit is contained in:
@@ -90,57 +90,50 @@ class TestAssignBrickReference:
|
||||
ifc.run("library.add_reference", library="library").should_be_called().will_return("reference")
|
||||
brick.export_brick_attributes("brick").should_be_called().will_return("attributes")
|
||||
ifc.run("library.edit_reference", reference="reference", attributes="attributes").should_be_called()
|
||||
ifc.get_entity("obj").should_be_called().will_return("product")
|
||||
ifc.run("library.assign_reference", product="product", reference="reference").should_be_called()
|
||||
ifc.run("library.assign_reference", product="element", reference="reference").should_be_called()
|
||||
brick.get_brickifc_project().should_be_called().will_return("project")
|
||||
brick.add_brickifc_reference("brick", "product", "project").should_be_called()
|
||||
subject.assign_brick_reference(ifc, brick, obj="obj", library="library", brick_uri="brick")
|
||||
brick.add_brickifc_reference("brick", "element", "project").should_be_called()
|
||||
subject.assign_brick_reference(ifc, brick, element="element", library="library", brick_uri="brick")
|
||||
|
||||
def test_assigning_to_an_existing_reference(self, ifc, brick):
|
||||
brick.get_library_brick_reference("library", "brick").should_be_called().will_return("reference")
|
||||
ifc.get_entity("obj").should_be_called().will_return("product")
|
||||
ifc.run("library.assign_reference", product="product", reference="reference").should_be_called()
|
||||
ifc.run("library.assign_reference", product="element", reference="reference").should_be_called()
|
||||
brick.get_brickifc_project().should_be_called().will_return("project")
|
||||
brick.add_brickifc_reference("brick", "product", "project").should_be_called()
|
||||
subject.assign_brick_reference(ifc, brick, obj="obj", library="library", brick_uri="brick")
|
||||
brick.add_brickifc_reference("brick", "element", "project").should_be_called()
|
||||
subject.assign_brick_reference(ifc, brick, element="element", library="library", brick_uri="brick")
|
||||
|
||||
def test_adding_a_brickifc_project_if_it_doesnt_exist(self, ifc, brick):
|
||||
brick.get_library_brick_reference("library", "brick").should_be_called().will_return("reference")
|
||||
ifc.get_entity("obj").should_be_called().will_return("product")
|
||||
ifc.run("library.assign_reference", product="product", reference="reference").should_be_called()
|
||||
ifc.run("library.assign_reference", product="element", reference="reference").should_be_called()
|
||||
brick.get_brickifc_project().should_be_called().will_return(None)
|
||||
brick.get_namespace("brick").should_be_called().will_return("namespace")
|
||||
brick.add_brickifc_project("namespace").should_be_called().will_return("project")
|
||||
brick.add_brickifc_reference("brick", "product", "project").should_be_called()
|
||||
subject.assign_brick_reference(ifc, brick, obj="obj", library="library", brick_uri="brick")
|
||||
brick.add_brickifc_reference("brick", "element", "project").should_be_called()
|
||||
subject.assign_brick_reference(ifc, brick, element="element", library="library", brick_uri="brick")
|
||||
|
||||
|
||||
class TestAddBrick:
|
||||
def test_adding_a_brick_from_an_element(self, ifc, brick):
|
||||
ifc.get_entity("obj").should_be_called().will_return("product")
|
||||
brick.add_brick_from_element("product", "namespace", "brick_class").should_be_called().will_return("brick_uri")
|
||||
brick.add_brick_from_element("element", "namespace", "brick_class").should_be_called().will_return("brick_uri")
|
||||
brick.run_refresh_brick_viewer().should_be_called()
|
||||
subject.add_brick(ifc, brick, obj="obj", namespace="namespace", brick_class="brick_class", library=None)
|
||||
subject.add_brick(ifc, brick, element="element", namespace="namespace", brick_class="brick_class", library=None)
|
||||
|
||||
def test_adding_a_brick_an_auto_assigning_it_to_the_ifc_element(self, ifc, brick):
|
||||
ifc.get_entity("obj").should_be_called().will_return("product")
|
||||
brick.add_brick_from_element("product", "namespace", "brick_class").should_be_called().will_return("brick_uri")
|
||||
brick.run_assign_brick_reference(obj="obj", library="library", brick_uri="brick_uri").should_be_called()
|
||||
brick.add_brick_from_element("element", "namespace", "brick_class").should_be_called().will_return("brick_uri")
|
||||
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, obj="obj", namespace="namespace", brick_class="brick_class", library="library")
|
||||
subject.add_brick(ifc, brick, element="element", namespace="namespace", brick_class="brick_class", library="library")
|
||||
|
||||
def test_adding_a_plain_brick(self, ifc, brick):
|
||||
brick.add_brick("namespace", "brick_class").should_be_called()
|
||||
brick.run_refresh_brick_viewer().should_be_called()
|
||||
subject.add_brick(ifc, brick, obj=None, namespace="namespace", brick_class="brick_class", library=None)
|
||||
subject.add_brick(ifc, brick, element=None, namespace="namespace", brick_class="brick_class", library=None)
|
||||
|
||||
|
||||
class TestAddBrickFeed:
|
||||
def test_run(self, ifc, brick):
|
||||
ifc.get_entity("source").should_be_called().will_return("source_element")
|
||||
ifc.get_entity("destination").should_be_called().will_return("destination_element")
|
||||
brick.get_brick("source_element").should_be_called().will_return("source_brick")
|
||||
brick.get_brick("destination_element").should_be_called().will_return("destination_brick")
|
||||
brick.get_brick("source").should_be_called().will_return("source_brick")
|
||||
brick.get_brick("destination").should_be_called().will_return("destination_brick")
|
||||
brick.add_feed("source_brick", "destination_brick").should_be_called()
|
||||
brick.run_refresh_brick_viewer().should_be_called()
|
||||
subject.add_brick_feed(ifc, brick, source="source", destination="destination")
|
||||
@@ -148,10 +141,10 @@ class TestAddBrickFeed:
|
||||
|
||||
class TestConvertIfcToBrick:
|
||||
def test_run(self, brick):
|
||||
brick.get_convertable_brick_objects_and_elements().should_be_called().will_return([("obj", "element")])
|
||||
brick.get_convertable_brick_elements().should_be_called().will_return(["element"])
|
||||
brick.get_brick_class("element").should_be_called().will_return("brick_class")
|
||||
brick.add_brick_from_element("element", "namespace", "brick_class").should_be_called().will_return("brick_uri")
|
||||
brick.run_assign_brick_reference(obj="obj", library="library", brick_uri="brick_uri").should_be_called()
|
||||
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.convert_ifc_to_brick(brick, namespace="namespace", library="library")
|
||||
|
||||
|
||||
@@ -238,15 +238,13 @@ class TestGetBrickifcProject(NewFile):
|
||||
)
|
||||
|
||||
|
||||
class TestGetConvertableBrickObjectsAndElements(NewFile):
|
||||
class TestGetConvertableBrickElements(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc.set(ifc)
|
||||
element = ifc.createIfcAirTerminalBox()
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
tool.Ifc.link(element, obj)
|
||||
ifc.createIfcWall()
|
||||
assert subject.get_convertable_brick_objects_and_elements() == [(obj, element)]
|
||||
assert subject.get_convertable_brick_elements() == {element}
|
||||
|
||||
|
||||
class TestGetItemClass(NewFile):
|
||||
|
||||
Reference in New Issue
Block a user