mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
ifc2x3 tests
This commit is contained in:
@@ -26,6 +26,10 @@ class TestAddPort(test.bootstrap.IFC4):
|
||||
assert ifcopenshell.api.run("system.add_port", self.file).is_a("IfcDistributionPort")
|
||||
|
||||
def test_assigning_a_port_as_well_if_an_element_is_specified(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcChiller")
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowTerminal")
|
||||
port = ifcopenshell.api.run("system.add_port", self.file, element=element)
|
||||
assert ifcopenshell.util.system.get_ports(element) == [port]
|
||||
|
||||
|
||||
class TestAddPortIFC2X3(test.bootstrap.IFC2X3, TestAddPort):
|
||||
pass
|
||||
|
||||
@@ -25,4 +25,11 @@ class TestAddSystem(test.bootstrap.IFC4):
|
||||
system = ifcopenshell.api.run("system.add_system", self.file, ifc_class="IfcSystem")
|
||||
system2 = ifcopenshell.api.run("system.add_system", self.file, ifc_class="IfcDistributionSystem")
|
||||
assert system.is_a("IfcSystem")
|
||||
assert system2.is_a("IfcDistributionSystem")
|
||||
if self.file.schema == "IFC2X3":
|
||||
assert system2.is_a("IfcSystem")
|
||||
else:
|
||||
assert system2.is_a("IfcDistributionSystem")
|
||||
|
||||
|
||||
class TestAddSystemIFC2X3(test.bootstrap.IFC2X3, TestAddSystem):
|
||||
pass
|
||||
|
||||
@@ -23,7 +23,7 @@ import ifcopenshell.api
|
||||
class TestAssignFlowControl(test.bootstrap.IFC4):
|
||||
def test_run(self):
|
||||
flow_element = self.file.createIfcFlowSegment()
|
||||
flow_control = self.file.createIfcController()
|
||||
flow_control = self.file.create_entity("IfcDistributionControlElement")
|
||||
|
||||
# simple assignment
|
||||
relation = ifcopenshell.api.run(
|
||||
@@ -56,7 +56,7 @@ class TestAssignFlowControl(test.bootstrap.IFC4):
|
||||
assert relation is None
|
||||
|
||||
# assigning another control to the same object
|
||||
flow_control1 = self.file.createIfcController()
|
||||
flow_control1 = self.file.create_entity("IfcDistributionControlElement")
|
||||
relation = ifcopenshell.api.run(
|
||||
"system.assign_flow_control",
|
||||
self.file,
|
||||
@@ -66,3 +66,7 @@ class TestAssignFlowControl(test.bootstrap.IFC4):
|
||||
assert len(self.file.by_type("IfcRelFlowControlElements")) == 1
|
||||
assert relation.RelatingFlowElement == flow_element
|
||||
assert set(relation.RelatedControlElements) == set((flow_control, flow_control1))
|
||||
|
||||
|
||||
class TestAssignFlowControlIFC2X3(test.bootstrap.IFC2X3, TestAssignFlowControl):
|
||||
pass
|
||||
|
||||
@@ -108,8 +108,12 @@ class TestConnectPort(test.bootstrap.IFC4):
|
||||
def test_connecting_ports_with_a_realising_element(self):
|
||||
port = ifcopenshell.api.run("system.add_port", self.file)
|
||||
port2 = ifcopenshell.api.run("system.add_port", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcDuctFitting")
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowFitting")
|
||||
ifcopenshell.api.run("system.connect_port", self.file, port1=port, port2=port2, element=element)
|
||||
assert self.file.by_type("IfcRelConnectsPorts")[0].RealizingElement == element
|
||||
ifcopenshell.api.run("system.connect_port", self.file, port1=port, port2=port2)
|
||||
assert self.file.by_type("IfcRelConnectsPorts")[0].RealizingElement is None
|
||||
|
||||
|
||||
class TestConnectPortIFC2X3(test.bootstrap.IFC2X3, TestConnectPort):
|
||||
pass
|
||||
|
||||
@@ -21,7 +21,7 @@ import ifcopenshell.api
|
||||
import ifcopenshell.util.system
|
||||
|
||||
|
||||
class TestConnectPort(test.bootstrap.IFC4):
|
||||
class TestDisconnectPort(test.bootstrap.IFC4):
|
||||
def test_disconnecting_a_port(self):
|
||||
port = ifcopenshell.api.run("system.add_port", self.file)
|
||||
port2 = ifcopenshell.api.run("system.add_port", self.file)
|
||||
@@ -30,3 +30,7 @@ class TestConnectPort(test.bootstrap.IFC4):
|
||||
assert port.FlowDirection == None
|
||||
assert port2.FlowDirection == None
|
||||
assert len(self.file.by_type("IfcRelConnectsPorts")) == 0
|
||||
|
||||
|
||||
class TestDisconnectPortIFC2X3(test.bootstrap.IFC2X3, TestDisconnectPort):
|
||||
pass
|
||||
|
||||
@@ -27,7 +27,7 @@ class TestRemoveSystem(test.bootstrap.IFC4):
|
||||
assert len(self.file.by_type("IfcSystem")) == 0
|
||||
|
||||
def test_removing_orphaned_group_relationships(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcPump")
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowTerminal")
|
||||
system = ifcopenshell.api.run("system.add_system", self.file, ifc_class="IfcSystem")
|
||||
ifcopenshell.api.run("system.assign_system", self.file, product=element, system=system)
|
||||
ifcopenshell.api.run("system.remove_system", self.file, system=system)
|
||||
@@ -41,3 +41,7 @@ class TestRemoveSystem(test.bootstrap.IFC4):
|
||||
assert not self.file.by_type("IfcRelDefinesByProperties")
|
||||
assert not self.file.by_type("IfcPropertySet")
|
||||
assert not self.file.by_type("IfcPropertySingleValue")
|
||||
|
||||
|
||||
class TestRemoveSystemIFC2X3(test.bootstrap.IFC2X3, TestRemoveSystem):
|
||||
pass
|
||||
|
||||
@@ -23,7 +23,7 @@ import ifcopenshell.api
|
||||
class TestUnassignFlowControl(test.bootstrap.IFC4):
|
||||
def test_run(self):
|
||||
flow_element = self.file.createIfcFlowSegment()
|
||||
flow_control = self.file.createIfcController()
|
||||
flow_control = self.file.create_entity("IfcDistributionControlElement")
|
||||
|
||||
# assign and unassign
|
||||
relation = ifcopenshell.api.run(
|
||||
@@ -41,7 +41,7 @@ class TestUnassignFlowControl(test.bootstrap.IFC4):
|
||||
assert len(self.file.by_type("IfcRelFlowControlElements")) == 0
|
||||
|
||||
# 1 element 2 controls
|
||||
flow_control1 = self.file.createIfcController()
|
||||
flow_control1 = self.file.create_entity("IfcDistributionControlElement")
|
||||
relation = ifcopenshell.api.run(
|
||||
"system.assign_flow_control",
|
||||
self.file,
|
||||
@@ -62,3 +62,7 @@ class TestUnassignFlowControl(test.bootstrap.IFC4):
|
||||
)
|
||||
assert len(self.file.by_type("IfcRelFlowControlElements")) == 1
|
||||
assert relation.RelatedControlElements == (flow_control,)
|
||||
|
||||
|
||||
class TestUnassignFlowControlIFC2X3(test.bootstrap.IFC2X3, TestUnassignFlowControl):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user