Replace all ifcopenshell.api.run with ifcopenshell.api static functions.

This commit is contained in:
Dion Moult
2024-06-28 12:36:31 +10:00
parent b5d613989e
commit 07060fc769
432 changed files with 4633 additions and 4856 deletions
@@ -19,6 +19,8 @@
import pytest
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.api.root
import ifcopenshell.api.system
import ifcopenshell.util.system as subject
@@ -34,31 +36,29 @@ class TestIsAssignable(test.bootstrap.IFC4):
class TestGetSystemElements(test.bootstrap.IFC4):
def test_run(self):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcPump")
system = ifcopenshell.api.run("system.add_system", self.file, ifc_class="IfcSystem")
ifcopenshell.api.run("system.assign_system", self.file, products=[element], system=system)
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcPump")
system = ifcopenshell.api.system.add_system(self.file, ifc_class="IfcSystem")
ifcopenshell.api.system.assign_system(self.file, products=[element], system=system)
assert subject.get_system_elements(system) == [element]
class TestGetElementSystems(test.bootstrap.IFC4):
def test_run(self):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcPump")
system = ifcopenshell.api.run("system.add_system", self.file, ifc_class="IfcSystem")
ifcopenshell.api.run("system.assign_system", self.file, products=[element], system=system)
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcPump")
system = ifcopenshell.api.system.add_system(self.file, ifc_class="IfcSystem")
ifcopenshell.api.system.assign_system(self.file, products=[element], system=system)
assert subject.get_element_systems(element) == [system]
def test_do_not_get_non_services_groups(self):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcPump")
ifcopenshell.api.run(
"system.assign_system",
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcPump")
ifcopenshell.api.system.assign_system(
self.file,
products=[element],
system=self.file.createIfcGroup(),
)
for not_assignable_system_class in ("IfcZone", "IfcStructuralAnalysisModel"):
with pytest.raises(TypeError):
ifcopenshell.api.run(
"system.assign_system",
ifcopenshell.api.system.assign_system(
self.file,
products=[element],
system=self.file.create_entity(not_assignable_system_class),
@@ -69,8 +69,8 @@ class TestGetElementSystems(test.bootstrap.IFC4):
class TestGetPorts(test.bootstrap.IFC4):
def test_run(self):
port = self.file.createIfcDistributionPort()
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
ifcopenshell.api.run("system.assign_port", self.file, element=element, port=port)
element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
ifcopenshell.api.system.assign_port(self.file, element=element, port=port)
assert subject.get_ports(element) == [port]
@@ -80,30 +80,30 @@ class TestGetPortsIFC2X3(test.bootstrap.IFC2X3, TestGetPorts):
class TestGetConnectedPort(test.bootstrap.IFC4):
def test_run(self):
port1 = ifcopenshell.api.run("system.add_port", self.file)
port2 = ifcopenshell.api.run("system.add_port", self.file)
ifcopenshell.api.run("system.connect_port", self.file, port1=port1, port2=port2)
port1 = ifcopenshell.api.system.add_port(self.file)
port2 = ifcopenshell.api.system.add_port(self.file)
ifcopenshell.api.system.connect_port(self.file, port1=port1, port2=port2)
assert subject.get_connected_port(port1) == port2
assert subject.get_connected_port(port2) == port1
class TestGetConnectedToFrom(test.bootstrap.IFC4):
def test_run(self):
port1 = ifcopenshell.api.run("system.add_port", self.file)
element1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
ifcopenshell.api.run("system.assign_port", self.file, element=element1, port=port1)
port1 = ifcopenshell.api.system.add_port(self.file)
element1 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
ifcopenshell.api.system.assign_port(self.file, element=element1, port=port1)
port2 = ifcopenshell.api.run("system.add_port", self.file)
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
ifcopenshell.api.run("system.assign_port", self.file, element=element2, port=port2)
port2 = ifcopenshell.api.system.add_port(self.file)
element2 = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcFlowSegment")
ifcopenshell.api.system.assign_port(self.file, element=element2, port=port2)
ifcopenshell.api.run("system.connect_port", self.file, port1=port1, port2=port2, direction="SOURCE")
ifcopenshell.api.system.connect_port(self.file, port1=port1, port2=port2, direction="SOURCE")
assert subject.get_connected_to(element1) == [element2]
assert subject.get_connected_from(element1) == []
assert subject.get_connected_to(element2) == []
assert subject.get_connected_from(element2) == [element1]
ifcopenshell.api.run("system.connect_port", self.file, port1=port1, port2=port2, direction="SINK")
ifcopenshell.api.system.connect_port(self.file, port1=port1, port2=port2, direction="SINK")
assert subject.get_connected_to(element1) == []
assert subject.get_connected_from(element1) == [element2]
assert subject.get_connected_to(element2) == [element1]