mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
Implement optionality in IfcTester, and generate integration testcases
This commit is contained in:
@@ -583,14 +583,14 @@ class TestAttribute:
|
||||
run(
|
||||
"Durations are treated as strings 1/2",
|
||||
facet=facet,
|
||||
inst=ifc.createIfcClassification(Name="Name", EditionDate="PT16H"),
|
||||
expected=False,
|
||||
inst=ifc.createIfcTaskTime(Name="Name", ScheduleDuration="PT16H"),
|
||||
expected=True,
|
||||
)
|
||||
ifc = ifcopenshell.file()
|
||||
run(
|
||||
"Durations are treated as strings 2/2",
|
||||
facet=facet,
|
||||
inst=ifc.createIfcClassification(Name="Name", EditionDate="P2D"),
|
||||
inst=ifc.createIfcTaskTime(Name="Name", ScheduleDuration="P2D"),
|
||||
expected=False,
|
||||
)
|
||||
|
||||
@@ -598,30 +598,27 @@ class TestAttribute:
|
||||
facet = Attribute(name=restriction)
|
||||
ifc = ifcopenshell.file()
|
||||
run(
|
||||
"Name restrictions may be used 1/4",
|
||||
"Name restrictions will match any result 1/3",
|
||||
facet=facet,
|
||||
inst=ifc.createIfcMaterialLayerSet(
|
||||
MaterialLayers=[ifc.createIfcMaterialLayer(LayerThickness=1)], LayerSetName="Foo"
|
||||
),
|
||||
expected=True,
|
||||
)
|
||||
ifc = ifcopenshell.file()
|
||||
run(
|
||||
"Name restrictions may be used 2/4",
|
||||
facet=facet,
|
||||
inst=ifc.createIfcMaterialConstituentSet(Name="Foo"),
|
||||
expected=True,
|
||||
)
|
||||
|
||||
restriction = Restriction(options=["Name", "Description"], type="enumeration")
|
||||
facet = Attribute(name=restriction)
|
||||
ifc = ifcopenshell.file()
|
||||
run("Name restrictions may be used 3/4", facet=facet, inst=ifc.createIfcWall(Name="Foo"), expected=False)
|
||||
run(
|
||||
"Name restrictions will match any result 2/3",
|
||||
facet=facet,
|
||||
inst=ifc.createIfcWall(Name="Foo"),
|
||||
expected=True,
|
||||
)
|
||||
ifc = ifcopenshell.file()
|
||||
run(
|
||||
"Name restrictions may be used 4/4",
|
||||
"Name restrictions will match any result 3/3",
|
||||
facet=facet,
|
||||
inst=ifc.createIfcWall(Name="Foo", Description="Bar"),
|
||||
inst=ifc.createIfcWall(Description="Bar"),
|
||||
expected=True,
|
||||
)
|
||||
|
||||
@@ -639,6 +636,7 @@ class TestAttribute:
|
||||
wall_type = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("type.assign_type", ifc, related_object=wall, relating_type=wall_type)
|
||||
wall_type.Description = "Foobar"
|
||||
facet = Attribute(name="Description", value="Foobar")
|
||||
run("Attributes are not inherited by the occurrence", facet=facet, inst=wall, expected=False)
|
||||
|
||||
restriction = Restriction(options=["42"], type="enumeration", base="string")
|
||||
@@ -857,18 +855,7 @@ class TestProperty:
|
||||
def test_filtering_using_a_property_facet(self):
|
||||
set_facet("property")
|
||||
|
||||
ifc = ifcopenshell.file()
|
||||
ifc.createIfcProject()
|
||||
# Milli prefix used to check measurement conversions
|
||||
lengthunit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="LENGTHUNIT", name="METRE", prefix="MILLI")
|
||||
areaunit = ifcopenshell.api.run(
|
||||
"unit.add_si_unit", ifc, unit_type="AREAUNIT", name="SQUARE_METRE", prefix="MILLI"
|
||||
)
|
||||
volumeunit = ifcopenshell.api.run(
|
||||
"unit.add_si_unit", ifc, unit_type="VOLUMEUNIT", name="CUBIC_METRE", prefix="MILLI"
|
||||
)
|
||||
timeunit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="TIMEUNIT", name="SECOND")
|
||||
ifcopenshell.api.run("unit.assign_unit", ifc, units=[lengthunit, areaunit, volumeunit, timeunit])
|
||||
ifc = self.setup_ifc()
|
||||
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", measure="IfcLabel")
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
@@ -876,11 +863,12 @@ class TestProperty:
|
||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"AnotherProperty": "AnotherValue"})
|
||||
run("Elements with a matching pset but no property also fail", facet=facet, inst=element, expected=False)
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": None})
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"AnotherProperty": None})
|
||||
run("Properties with a null value fail", facet=facet, inst=element, expected=False)
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Bar"})
|
||||
run("A name check will match any property with any string value", facet=facet, inst=element, expected=True)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", measure="IfcLabel")
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
||||
@@ -912,6 +900,7 @@ class TestProperty:
|
||||
expected=True,
|
||||
)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="Bar", measure="IfcLabel")
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
||||
@@ -933,6 +922,7 @@ class TestProperty:
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcIdentifier(identifier)})
|
||||
run("IDS does not handle string truncation such as for identifiers", facet=facet, inst=element, expected=False)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="1", measure="IfcLabel")
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
||||
@@ -1009,6 +999,7 @@ class TestProperty:
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcDuration("P2D")})
|
||||
run("Durations are treated as strings 1/2", facet=facet, inst=element, expected=False)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Pset_WallCommon")
|
||||
pset_template = ifcopenshell.util.pset.get_template("IFC4").get_by_name("Pset_WallCommon")
|
||||
@@ -1026,6 +1017,7 @@ class TestProperty:
|
||||
facet = Property(propertySet="Pset_WallCommon", name="Status", value="NEW", measure="IfcLabel")
|
||||
run("Any matching value in an enumerated property will pass 3/3", facet=facet, inst=element, expected=False)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
||||
list_property = ifc.createIfcPropertyListValue(
|
||||
@@ -1039,6 +1031,7 @@ class TestProperty:
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="Z", measure="IfcLabel")
|
||||
run("Any matching value in a list property will pass 3/3", facet=facet, inst=element, expected=False)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
||||
bounded_property = ifc.createIfcPropertyBoundedValue(
|
||||
@@ -1057,6 +1050,7 @@ class TestProperty:
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="2", measure="IfcLengthMeasure")
|
||||
run("Any matching value in a bounded property will pass 4/4", facet=facet, inst=element, expected=False)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
||||
table_property = ifc.createIfcPropertyTableValue(
|
||||
@@ -1070,12 +1064,14 @@ class TestProperty:
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="Y", measure="IfcLabel")
|
||||
run("Any matching value in a table property will pass 3/3", facet=facet, inst=element, expected=False)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
||||
pset.HasProperties = [ifc.createIfcPropertyReferenceValue(Name="Foo")]
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", measure="IfcLabel")
|
||||
run("Reference properties are treated as objects and not supported", facet=facet, inst=element, expected=False)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcDoor")
|
||||
pset = ifc.create_entity(
|
||||
"IfcDoorPanelProperties",
|
||||
@@ -1099,6 +1095,7 @@ class TestProperty:
|
||||
)
|
||||
run("Predefined properties are supported but discouraged 2/2", facet=facet, inst=element, expected=False)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", measure="IfcLengthMeasure")
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
qto = ifcopenshell.api.run("pset.add_qto", ifc, product=element, name="Foo_Bar")
|
||||
@@ -1107,6 +1104,7 @@ class TestProperty:
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", measure="IfcAreaMeasure")
|
||||
run("Quantities must also match the appropriate measure", facet=facet, inst=element, expected=False)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
||||
complex_property = ifc.createIfcComplexProperty(Name="Foo", UsageName="RabbitAgilityTraining")
|
||||
@@ -1117,6 +1115,7 @@ class TestProperty:
|
||||
facet = Property(propertySet="Foo", name="Rabbits", measure="IfcLabel")
|
||||
run("Complex properties are not supported 2/2", facet=facet, inst=element, expected=False)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
qto = ifcopenshell.api.run("pset.add_qto", ifc, product=element, name="Foo_Bar")
|
||||
complex_quantity = ifc.createIfcPhysicalComplexQuantity(Name="Foo", Discrimination="FurThickness")
|
||||
@@ -1129,6 +1128,7 @@ class TestProperty:
|
||||
facet = Property(propertySet="Foo", name="MyLength", measure="IfcLengthMeasure")
|
||||
run("Complex properties are not supported 2/2", facet=facet, inst=element, expected=False)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
restriction = Restriction(options="Foo_.*", type="pattern")
|
||||
facet = Property(propertySet=restriction, name="Foo", measure="IfcLabel")
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
@@ -1141,6 +1141,7 @@ class TestProperty:
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Bar"})
|
||||
run("All matching property sets must satisfy requirements 3/3", facet=facet, inst=element, expected=True)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
restriction = Restriction(options="Foo.*", type="pattern")
|
||||
facet = Property(propertySet="Foo_Bar", name=restriction, value="x", measure="IfcLabel")
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
@@ -1152,6 +1153,7 @@ class TestProperty:
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": "x", "Foobaz": "y"})
|
||||
run("All matching properties must satisfy requirements 3/3", facet=facet, inst=element, expected=False)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
restriction1 = Restriction(options="Foo.*", type="pattern")
|
||||
restriction2 = Restriction(options=["x", "y"], type="enumeration")
|
||||
facet = Property(propertySet="Foo_Bar", name=restriction1, value=restriction2, measure="IfcLabel")
|
||||
@@ -1172,6 +1174,7 @@ class TestProperty:
|
||||
expected=False,
|
||||
)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="2", measure="IfcTimeMeasure")
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
||||
@@ -1180,6 +1183,7 @@ class TestProperty:
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcTimeMeasure(2)})
|
||||
run("Measures are used to specify an IFC data type 2/2", facet=facet, inst=element, expected=True)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="2", measure="IfcLengthMeasure")
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
||||
@@ -1198,6 +1202,7 @@ class TestProperty:
|
||||
expected=True,
|
||||
)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
wall = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
wall_type = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("type.assign_type", ifc, related_object=wall, relating_type=wall_type)
|
||||
@@ -1207,6 +1212,7 @@ class TestProperty:
|
||||
run("Properties can be inherited from the type 1/2", facet=facet, inst=wall, expected=True)
|
||||
run("Properties can be inherited from the type 2/2", facet=facet, inst=wall_type, expected=True)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
wall = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
wall_type = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWallType")
|
||||
ifcopenshell.api.run("type.assign_type", ifc, related_object=wall, relating_type=wall_type)
|
||||
@@ -1218,6 +1224,21 @@ class TestProperty:
|
||||
run("Properties can be overriden by an occurrence 1/2", facet=facet, inst=wall, expected=True)
|
||||
run("Properties can be overriden by an occurrence 2/2", facet=facet, inst=wall_type, expected=False)
|
||||
|
||||
def setup_ifc(self):
|
||||
ifc = ifcopenshell.file()
|
||||
ifc.createIfcProject()
|
||||
# Milli prefix used to check measurement conversions
|
||||
lengthunit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="LENGTHUNIT", name="METRE", prefix="MILLI")
|
||||
areaunit = ifcopenshell.api.run(
|
||||
"unit.add_si_unit", ifc, unit_type="AREAUNIT", name="SQUARE_METRE", prefix="MILLI"
|
||||
)
|
||||
volumeunit = ifcopenshell.api.run(
|
||||
"unit.add_si_unit", ifc, unit_type="VOLUMEUNIT", name="CUBIC_METRE", prefix="MILLI"
|
||||
)
|
||||
timeunit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="TIMEUNIT", name="SECOND")
|
||||
ifcopenshell.api.run("unit.assign_unit", ifc, units=[lengthunit, areaunit, volumeunit, timeunit])
|
||||
return ifc
|
||||
|
||||
|
||||
class TestMaterial:
|
||||
def test_creating_a_material_facet(self):
|
||||
@@ -1258,7 +1279,6 @@ class TestMaterial:
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", ifc)
|
||||
ifcopenshell.api.run("material.assign_material", ifc, product=element, material=material)
|
||||
run("Material with no data will fail a value check", facet=facet, inst=element, expected=False)
|
||||
material.Name = "Foo"
|
||||
run("A material name may pass the value check", facet=facet, inst=element, expected=True)
|
||||
material.Name = "Bar"
|
||||
@@ -1270,7 +1290,6 @@ class TestMaterial:
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
material_set = ifcopenshell.api.run("material.add_material_set", ifc, set_type="IfcMaterialList")
|
||||
ifcopenshell.api.run("material.assign_material", ifc, product=element, material=material_set)
|
||||
run("A material list with no data will fail a value check", facet=facet, inst=element, expected=False)
|
||||
material = ifcopenshell.api.run("material.add_material", ifc)
|
||||
ifcopenshell.api.run("material.add_list_item", ifc, material_list=material_set, material=material)
|
||||
material.Name = "Foo"
|
||||
@@ -1418,6 +1437,7 @@ class TestPartOf:
|
||||
run("An optional facet always passes regardless of outcome 1/2", facet=facet, inst=element, expected=True)
|
||||
run("An optional facet always passes regardless of outcome 2/2", facet=facet, inst=subelement, expected=True)
|
||||
|
||||
ifc = ifcopenshell.file()
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcSlab")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcBeam")
|
||||
ifcopenshell.api.run("aggregate.assign_object", ifc, product=subelement, relating_object=element)
|
||||
@@ -1426,6 +1446,7 @@ class TestPartOf:
|
||||
facet = PartOf(entity="IFCWALL", relation="IfcRelAggregates")
|
||||
run("An aggregate may specify the entity of the whole 2/2", facet=facet, inst=subelement, expected=False)
|
||||
|
||||
ifc = ifcopenshell.file()
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcElementAssembly")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcSlab")
|
||||
subsubelement = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcBeam")
|
||||
@@ -1434,6 +1455,7 @@ class TestPartOf:
|
||||
facet = PartOf(entity="IFCELEMENTASSEMBLY", relation="IfcRelAggregates")
|
||||
run("An aggregate entity may pass any ancestral whole passes", facet=facet, inst=subsubelement, expected=True)
|
||||
|
||||
ifc = ifcopenshell.file()
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcElementAssembly")
|
||||
group = ifcopenshell.api.run("group.add_group", ifc)
|
||||
facet = PartOf(relation="IfcRelAssignsToGroup")
|
||||
@@ -1441,6 +1463,7 @@ class TestPartOf:
|
||||
ifcopenshell.api.run("group.assign_group", ifc, products=[element], group=group)
|
||||
run("A grouped element passes a group relationship", facet=facet, inst=element, expected=True)
|
||||
|
||||
ifc = ifcopenshell.file()
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcElementAssembly")
|
||||
group = ifc.createIfcInventory()
|
||||
facet = PartOf(entity="IFCGROUP", relation="IfcRelAssignsToGroup")
|
||||
@@ -1449,6 +1472,7 @@ class TestPartOf:
|
||||
facet = PartOf(entity="IFCINVENTORY", relation="IfcRelAssignsToGroup")
|
||||
run("A group entity must match exactly 2/2", facet=facet, inst=element, expected=True)
|
||||
|
||||
ifc = ifcopenshell.file()
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcElementAssembly")
|
||||
container = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcSpace")
|
||||
facet = PartOf(relation="IfcRelContainedInSpatialStructure")
|
||||
@@ -1457,6 +1481,7 @@ class TestPartOf:
|
||||
run("Any contained element passes a containment relationship 2/2", facet=facet, inst=element, expected=True)
|
||||
run("The container itself always fails", facet=facet, inst=container, expected=False)
|
||||
|
||||
ifc = ifcopenshell.file()
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcElementAssembly")
|
||||
container = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcSpace")
|
||||
ifcopenshell.api.run("spatial.assign_container", ifc, product=element, relating_structure=container)
|
||||
@@ -1465,6 +1490,7 @@ class TestPartOf:
|
||||
facet = PartOf(relation="IfcRelContainedInSpatialStructure", entity="IFCSPACE")
|
||||
run("The container entity must match exactly 2/2", facet=facet, inst=element, expected=True)
|
||||
|
||||
ifc = ifcopenshell.file()
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcSlab")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcBeam")
|
||||
ifcopenshell.api.run("aggregate.assign_object", ifc, product=subelement, relating_object=element)
|
||||
@@ -1473,6 +1499,7 @@ class TestPartOf:
|
||||
facet = PartOf(relation="IfcRelContainedInSpatialStructure", entity="IFCSPACE")
|
||||
run("The container may be indirect", facet=facet, inst=subelement, expected=True)
|
||||
|
||||
ifc = ifcopenshell.file()
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcFurniture")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcDiscreteAccessory")
|
||||
ifcopenshell.api.run("nest.assign_object", ifc, related_object=subelement, relating_object=element)
|
||||
@@ -1480,6 +1507,7 @@ class TestPartOf:
|
||||
run("Any nested part passes a nest relationship", facet=facet, inst=subelement, expected=True)
|
||||
run("Any nested whole fails a nest relationship", facet=facet, inst=element, expected=False)
|
||||
|
||||
ifc = ifcopenshell.file()
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcFurniture")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcDiscreteAccessory")
|
||||
ifcopenshell.api.run("nest.assign_object", ifc, related_object=subelement, relating_object=element)
|
||||
@@ -1488,6 +1516,7 @@ class TestPartOf:
|
||||
facet = PartOf(relation="IfcRelNests", entity="IFCFURNITURE")
|
||||
run("The nest entity must match exactly 2/2", facet=facet, inst=subelement, expected=True)
|
||||
|
||||
ifc = ifcopenshell.file()
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcFurniture")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcDiscreteAccessory")
|
||||
subsubelement = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcMechanicalFastener")
|
||||
@@ -1516,3 +1545,47 @@ class TestRestriction:
|
||||
assert restriction == "AB01"
|
||||
assert restriction != "AB"
|
||||
assert restriction != "01"
|
||||
|
||||
def test_filtering_using_an_enumeration(self):
|
||||
set_facet("restriction")
|
||||
|
||||
ifc = ifcopenshell.file()
|
||||
restriction = Restriction(options=["Foo", "Bar"], type="enumeration")
|
||||
facet = Attribute(name="Name", value=restriction)
|
||||
element = ifc.createIfcWall(Name="Foo")
|
||||
run("An enumeration matches case sensitively 1/3", facet=facet, inst=element, expected=True)
|
||||
element.Name = "Bar"
|
||||
run("An enumeration matches case sensitively 1/3", facet=facet, inst=element, expected=True)
|
||||
element.Name = "Baz"
|
||||
run("An enumeration matches case sensitively 1/3", facet=facet, inst=element, expected=False)
|
||||
|
||||
ifc = ifcopenshell.file()
|
||||
restriction = Restriction(options={"minInclusive": 0, "maxInclusive": 10}, type="bounds", base="integer")
|
||||
element = ifc.createIfcSurfaceStyleRefraction(RefractionIndex=0)
|
||||
facet = Attribute(name="RefractionIndex", value=restriction)
|
||||
run("A bound can be inclusive 1/4", facet=facet, inst=element, expected=True)
|
||||
element.RefractionIndex = 5
|
||||
run("A bound can be inclusive 2/4", facet=facet, inst=element, expected=True)
|
||||
element.RefractionIndex = 10
|
||||
run("A bound can be inclusive 3/4", facet=facet, inst=element, expected=True)
|
||||
element.RefractionIndex = 100
|
||||
run("A bound can be inclusive 4/4", facet=facet, inst=element, expected=False)
|
||||
|
||||
restriction = Restriction(options={"minExclusive": 0, "maxExclusive": 10}, type="bounds", base="integer")
|
||||
facet = Attribute(name="RefractionIndex", value=restriction)
|
||||
element.RefractionIndex = 0
|
||||
run("A bound can be inclusive 1/3", facet=facet, inst=element, expected=False)
|
||||
element.RefractionIndex = 5
|
||||
run("A bound can be inclusive 2/3", facet=facet, inst=element, expected=True)
|
||||
element.RefractionIndex = 10
|
||||
run("A bound can be inclusive 3/3", facet=facet, inst=element, expected=False)
|
||||
|
||||
ifc = ifcopenshell.file()
|
||||
restriction = Restriction(options="[A-Z]{2}[0-9]{2}", type="pattern")
|
||||
facet = Attribute(name="Name", value=restriction)
|
||||
element = ifc.createIfcWall(Name="WT01")
|
||||
run("Regex patterns can be used 1/3", facet=facet, inst=element, expected=True)
|
||||
element.Name = "XY99"
|
||||
run("Regex patterns can be used 2/3", facet=facet, inst=element, expected=True)
|
||||
element.Name = "A5"
|
||||
run("Regex patterns can be used 3/3", facet=facet, inst=element, expected=False)
|
||||
|
||||
Reference in New Issue
Block a user