mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 02:47:48 +00:00
unify tests for ifc4 and ifc2x3
This commit is contained in:
@@ -301,13 +301,8 @@ class TestGetTypeIFC4(test.bootstrap.IFC4):
|
||||
assert subject.get_type(element_type) == element_type
|
||||
|
||||
|
||||
class TestGetTypeIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_getting_the_type_of_a_product(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_object=element, relating_type=element_type)
|
||||
assert subject.get_type(element) == element_type
|
||||
assert subject.get_type(element_type) == element_type
|
||||
class TestGetTypeIFC2X3(test.bootstrap.IFC2X3, TestGetTypeIFC4):
|
||||
pass
|
||||
|
||||
|
||||
class TestGetTypes(test.bootstrap.IFC4):
|
||||
@@ -318,12 +313,8 @@ class TestGetTypes(test.bootstrap.IFC4):
|
||||
assert subject.get_types(element_type) == (element,)
|
||||
|
||||
|
||||
class TestGetTypesIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_getting_the_type_of_a_product(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("type.assign_type", self.file, related_object=element, relating_type=element_type)
|
||||
assert subject.get_types(element_type) == (element,)
|
||||
class TestGetTypesIFC2X3(test.bootstrap.IFC2X3, TestGetTypes):
|
||||
pass
|
||||
|
||||
|
||||
class TestGetShapeAspects(test.bootstrap.IFC4):
|
||||
@@ -645,42 +636,6 @@ class TestGetElementsByLayer(test.bootstrap.IFC4):
|
||||
assert list(subject.get_elements_by_layer(self.file, layer)) == [element]
|
||||
|
||||
|
||||
class TestGetlayers(test.bootstrap.IFC4):
|
||||
def test_getting_the_layer_of_a_product_representation(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
layer = ifcopenshell.api.run("layer.add_layer", self.file)
|
||||
representation = self.file.createIfcShapeRepresentation()
|
||||
element.Representation = self.file.createIfcProductDefinitionShape(Representations=[representation])
|
||||
ifcopenshell.api.run("layer.assign_layer", self.file, items=[representation], layer=layer)
|
||||
assert subject.get_layers(self.file, element) == [layer]
|
||||
|
||||
def test_getting_the_layer_of_a_product_item(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
layer = ifcopenshell.api.run("layer.add_layer", self.file)
|
||||
item = self.file.createIfcExtrudedAreaSolid()
|
||||
representation = self.file.createIfcShapeRepresentation(Items=[item])
|
||||
element.Representation = self.file.createIfcProductDefinitionShape(Representations=[representation])
|
||||
ifcopenshell.api.run("layer.assign_layer", self.file, items=[item], layer=layer)
|
||||
assert subject.get_layers(self.file, element) == [layer]
|
||||
|
||||
def test_getting_the_layer_of_a_type_product_representation(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
layer = ifcopenshell.api.run("layer.add_layer", self.file)
|
||||
representation = self.file.createIfcShapeRepresentation()
|
||||
element.RepresentationMaps = [self.file.createIfcRepresentationMap(MappedRepresentation=representation)]
|
||||
ifcopenshell.api.run("layer.assign_layer", self.file, items=[representation], layer=layer)
|
||||
assert subject.get_layers(self.file, element) == [layer]
|
||||
|
||||
def test_getting_the_layer_of_a_type_product_item(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
layer = ifcopenshell.api.run("layer.add_layer", self.file)
|
||||
item = self.file.createIfcExtrudedAreaSolid()
|
||||
representation = self.file.createIfcShapeRepresentation(Items=[item])
|
||||
element.RepresentationMaps = [self.file.createIfcRepresentationMap(MappedRepresentation=representation)]
|
||||
ifcopenshell.api.run("layer.assign_layer", self.file, items=[item], layer=layer)
|
||||
assert subject.get_layers(self.file, element) == [layer]
|
||||
|
||||
|
||||
class TestGetlayersIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_getting_the_layer_of_a_product_item(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
@@ -701,6 +656,24 @@ class TestGetlayersIFC2X3(test.bootstrap.IFC2X3):
|
||||
assert subject.get_layers(self.file, element) == [layer]
|
||||
|
||||
|
||||
class TestGetlayers(test.bootstrap.IFC4, TestGetlayersIFC2X3):
|
||||
def test_getting_the_layer_of_a_product_representation(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
layer = ifcopenshell.api.run("layer.add_layer", self.file)
|
||||
representation = self.file.createIfcShapeRepresentation()
|
||||
element.Representation = self.file.createIfcProductDefinitionShape(Representations=[representation])
|
||||
ifcopenshell.api.run("layer.assign_layer", self.file, items=[representation], layer=layer)
|
||||
assert subject.get_layers(self.file, element) == [layer]
|
||||
|
||||
def test_getting_the_layer_of_a_type_product_representation(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
layer = ifcopenshell.api.run("layer.add_layer", self.file)
|
||||
representation = self.file.createIfcShapeRepresentation()
|
||||
element.RepresentationMaps = [self.file.createIfcRepresentationMap(MappedRepresentation=representation)]
|
||||
ifcopenshell.api.run("layer.assign_layer", self.file, items=[representation], layer=layer)
|
||||
assert subject.get_layers(self.file, element) == [layer]
|
||||
|
||||
|
||||
class TestGetContainerIFC4(test.bootstrap.IFC4):
|
||||
def test_getting_the_spatial_container_of_an_element(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
|
||||
@@ -57,14 +57,6 @@ 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="IfcChiller")
|
||||
ifcopenshell.api.run("system.assign_port", self.file, element=element, port=port)
|
||||
assert subject.get_ports(element) == [port]
|
||||
|
||||
|
||||
class TestGetPortsIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_run(self):
|
||||
port = self.file.createIfcDistributionPort()
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcFlowSegment")
|
||||
@@ -72,6 +64,10 @@ class TestGetPortsIFC2X3(test.bootstrap.IFC2X3):
|
||||
assert subject.get_ports(element) == [port]
|
||||
|
||||
|
||||
class TestGetPortsIFC2X3(test.bootstrap.IFC2X3, TestGetPorts):
|
||||
pass
|
||||
|
||||
|
||||
class TestGetConnectedPort(test.bootstrap.IFC4):
|
||||
def test_run(self):
|
||||
port1 = ifcopenshell.api.run("system.add_port", self.file)
|
||||
@@ -104,6 +100,5 @@ class TestGetConnectedToFrom(test.bootstrap.IFC4):
|
||||
assert subject.get_connected_from(element2) == []
|
||||
|
||||
|
||||
class TestGetConnectedToFromIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_run(self):
|
||||
TestGetConnectedToFrom.test_run(self)
|
||||
class TestGetConnectedToFromIFC2X3(test.bootstrap.IFC2X3, TestGetConnectedToFrom):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user