mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Fixed most issues with IDS auditing
This commit is contained in:
committed by
Dion Moult
parent
e4bfb05875
commit
2661999f3e
@@ -286,7 +286,7 @@ class Attribute(Facet):
|
||||
|
||||
|
||||
class Classification(Facet):
|
||||
def __init__(self, value=None, system=None, uri=None, minOccurs=None, maxOccurs=None, instructions=None):
|
||||
def __init__(self, value=None, system=None, uri=None, minOccurs=None, maxOccurs="unbounded", instructions=None):
|
||||
self.parameters = ["value", "system", "@uri", "@minOccurs", "@maxOccurs", "@instructions"]
|
||||
self.applicability_templates = [
|
||||
"Data having a {system} reference of {value}",
|
||||
@@ -347,7 +347,7 @@ class PartOf(Facet):
|
||||
predefinedType=None,
|
||||
relation=None,
|
||||
minOccurs=None,
|
||||
maxOccurs=None,
|
||||
maxOccurs="unbounded",
|
||||
instructions=None,
|
||||
):
|
||||
self.parameters = ["entity", "predefinedType", "@relation", "@minOccurs", "@maxOccurs", "@instructions"]
|
||||
@@ -552,7 +552,7 @@ class Property(Facet):
|
||||
datatype=None,
|
||||
uri=None,
|
||||
minOccurs=None,
|
||||
maxOccurs=None,
|
||||
maxOccurs="unbounded",
|
||||
instructions=None,
|
||||
):
|
||||
self.parameters = [
|
||||
@@ -824,7 +824,7 @@ class Property(Facet):
|
||||
|
||||
|
||||
class Material(Facet):
|
||||
def __init__(self, value=None, uri=None, minOccurs=None, maxOccurs=None, instructions=None):
|
||||
def __init__(self, value=None, uri=None, minOccurs=None, maxOccurs="unbounded", instructions=None):
|
||||
self.parameters = ["value", "@uri", "@minOccurs", "@maxOccurs", "@instructions"]
|
||||
self.applicability_templates = [
|
||||
"All data with a {value} material",
|
||||
|
||||
@@ -81,7 +81,9 @@ class FacetDocGenerator:
|
||||
# Create an IDS with the applicability selecting exactly
|
||||
# the entity type passed to us in `inst`.
|
||||
specs = ids.Ids(title=name)
|
||||
spec = ids.Specification(name=name, minOccurs=1)
|
||||
|
||||
# todo: to resume IFC2X3 we need to ensure that entities and attributes are consistent with that schema in order to pass audit
|
||||
spec = ids.Specification(name=name, minOccurs=1, ifcVersion=["IFC4"])
|
||||
spec.applicability.append(ids.Entity(name=inst.is_a().upper()))
|
||||
spec.requirements.append(facet)
|
||||
specs.specifications.append(spec)
|
||||
|
||||
@@ -667,9 +667,11 @@ class TestAttribute:
|
||||
class TestClassification:
|
||||
def test_creating_a_classification_facet(self):
|
||||
facet = Classification()
|
||||
assert facet.asdict() == {}
|
||||
assert facet.asdict() == {
|
||||
"@maxOccurs": "unbounded"
|
||||
}
|
||||
facet = Classification(value="value", system="system")
|
||||
assert facet.asdict() == {"value": {"simpleValue": "value"}, "system": {"simpleValue": "system"}}
|
||||
assert facet.asdict() == {"value": {"simpleValue": "value"}, "system": {"simpleValue": "system"}, "@maxOccurs": "unbounded" }
|
||||
facet = Classification(
|
||||
value="value",
|
||||
system="system",
|
||||
@@ -834,6 +836,7 @@ class TestProperty:
|
||||
assert facet.asdict() == {
|
||||
"propertySet": {"simpleValue": "Property_Set"},
|
||||
"name": {"simpleValue": "PropertyName"},
|
||||
"@maxOccurs": "unbounded"
|
||||
}
|
||||
facet = Property(
|
||||
propertySet="propertySet",
|
||||
@@ -861,7 +864,7 @@ class TestProperty:
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="IfcLabel")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="IFCLABEL")
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
run("Elements with no properties always fail", facet=facet, inst=element, expected=False)
|
||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=element, name="Foo_Bar")
|
||||
@@ -873,27 +876,27 @@ class TestProperty:
|
||||
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", datatype="IfcLabel")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="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")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Bar"})
|
||||
run("A required facet checks all parameters as normal", facet=facet, inst=element, expected=True)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="IfcLabel", minOccurs=0, maxOccurs=0)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="IFCLABEL", minOccurs=0, maxOccurs=0)
|
||||
run("A prohibited facet returns the opposite of a required facet", facet=facet, inst=element, expected=False)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="IfcLabel", minOccurs=0)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="IFCLABEL", minOccurs=0)
|
||||
run("An optional facet always passes regardless of outcome 1/2", facet=facet, inst=element, expected=True)
|
||||
facet = Property(propertySet="Foo_Bar", name="Bar", datatype="IfcLabel", minOccurs=0)
|
||||
facet = Property(propertySet="Foo_Bar", name="Bar", datatype="IFCLABEL", minOccurs=0)
|
||||
run("An optional facet always passes regardless of outcome 2/2", facet=facet, inst=element, expected=True)
|
||||
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ""})
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="IfcLogical")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="IFCLOGICAL")
|
||||
run("An empty string is considered falsey and will not pass", facet=facet, inst=element, expected=False)
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcLogical("UNKNOWN")})
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="IfcDuration")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="IFCDURATION")
|
||||
run("A logical unknown is considered falsey and will not pass", facet=facet, inst=element, expected=False)
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcDuration("P0D")})
|
||||
run("A zero duration will pass", facet=facet, inst=element, expected=True)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="IfcBoolean")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="IFCBOOLEAN")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcBoolean(True)})
|
||||
run("A property set to true will pass a name check", facet=facet, inst=element, expected=True)
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": False})
|
||||
@@ -905,7 +908,7 @@ class TestProperty:
|
||||
)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="Bar", datatype="IfcLabel")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="Bar", datatype="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")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Bar"})
|
||||
@@ -915,55 +918,55 @@ class TestProperty:
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Baz"})
|
||||
run("Specifying a value fails against different values", facet=facet, inst=element, expected=False)
|
||||
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="♫Don'tÄrgerhôtelЊет", datatype="IfcLabel")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="♫Don'tÄrgerhôtelЊет", datatype="IFCLABEL")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "♫Don'tÄrgerhôtelЊет"})
|
||||
run("Non-ascii characters are treated without encoding", facet=facet, inst=element, expected=True)
|
||||
|
||||
identifier = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345"
|
||||
facet = Property(
|
||||
propertySet="Foo_Bar", name="Foo", value=identifier + "_extra_characters", datatype="IfcIdentifier"
|
||||
propertySet="Foo_Bar", name="Foo", value=identifier + "_extra_characters", datatype="IFCIDENTIFIER"
|
||||
)
|
||||
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", datatype="IfcLabel")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="1", datatype="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")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "1"})
|
||||
run("A number specified as a string is treated as a string", facet=facet, inst=element, expected=True)
|
||||
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="42", datatype="IfcInteger")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="42", datatype="IFCINTEGER")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcInteger(42)})
|
||||
run("Integer values are checked using type casting 1/4", facet=facet, inst=element, expected=True)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="42.", datatype="IfcInteger")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="42.", datatype="IFCINTEGER")
|
||||
run("Integer values are checked using type casting 2/4", facet=facet, inst=element, expected=True)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="42.0", datatype="IfcInteger")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="42.0", datatype="IFCINTEGER")
|
||||
run("Integer values are checked using type casting 3/4", facet=facet, inst=element, expected=True)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="42.3", datatype="IfcInteger")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="42.3", datatype="IFCINTEGER")
|
||||
run("Integer values are checked using type casting 4/4", facet=facet, inst=element, expected=False)
|
||||
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="42", datatype="IfcReal")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="42", datatype="IFCREAL")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcReal(42.0)})
|
||||
run("Real values are checked using type casting 1/3", facet=facet, inst=element, expected=True)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="42.0", datatype="IfcReal")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="42.0", datatype="IFCREAL")
|
||||
run("Real values are checked using type casting 2/3", facet=facet, inst=element, expected=True)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="42.3", datatype="IfcReal")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="42.3", datatype="IFCREAL")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcReal(42.3)})
|
||||
run("Real values are checked using type casting 3/3", facet=facet, inst=element, expected=True)
|
||||
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="42,3", datatype="IfcReal")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="42,3", datatype="IFCREAL")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcReal(42.3)})
|
||||
run("Only specifically formatted numbers are allowed 1/4", facet=facet, inst=element, expected=False)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="123,4.5", datatype="IfcReal")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="123,4.5", datatype="IFCREAL")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcReal(1234.5)})
|
||||
run("Only specifically formatted numbers are allowed 2/4", facet=facet, inst=element, expected=False)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="1.2345e3", datatype="IfcReal")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="1.2345e3", datatype="IFCREAL")
|
||||
run("Only specifically formatted numbers are allowed 3/4", facet=facet, inst=element, expected=True)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="1.2345E3", datatype="IfcReal")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="1.2345E3", datatype="IFCREAL")
|
||||
run("Only specifically formatted numbers are allowed 4/4", facet=facet, inst=element, expected=True)
|
||||
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="42.", datatype="IfcReal")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="42.", datatype="IFCREAL")
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcReal(42.0 * (1.0 + 1e-6))}
|
||||
)
|
||||
@@ -981,15 +984,15 @@ class TestProperty:
|
||||
)
|
||||
run("Floating point numbers are compared with a 1e-6 tolerance 4/4", facet=facet, inst=element, expected=False)
|
||||
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="TRUE", datatype="IfcBoolean")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="TRUE", datatype="IFCBOOLEAN")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcBoolean(False)})
|
||||
run("Booleans must be specified as uppercase strings 1/3", facet=facet, inst=element, expected=False)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="FALSE", datatype="IfcBoolean")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="FALSE", datatype="IFCBOOLEAN")
|
||||
run("Booleans must be specified as uppercase strings 2/3", facet=facet, inst=element, expected=True)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="False", datatype="IfcBoolean")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="False", datatype="IFCBOOLEAN")
|
||||
run("Booleans must be specified as uppercase strings 3/3", facet=facet, inst=element, expected=False)
|
||||
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="2022-01-01", datatype="IfcDate")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="2022-01-01", datatype="IFCDATE")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcDate("2022-01-01")})
|
||||
run("Dates are treated as strings 1/2", facet=facet, inst=element, expected=True)
|
||||
ifcopenshell.api.run(
|
||||
@@ -997,7 +1000,7 @@ class TestProperty:
|
||||
)
|
||||
run("Dates are treated as strings 2/2", facet=facet, inst=element, expected=False)
|
||||
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="PT16H", datatype="IfcDuration")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="PT16H", datatype="IFCDURATION")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcDuration("PT16H")})
|
||||
run("Durations are treated as strings 1/2", facet=facet, inst=element, expected=True)
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcDuration("P2D")})
|
||||
@@ -1014,11 +1017,11 @@ class TestProperty:
|
||||
properties={"Status": ["EXISTING", "DEMOLISH"]},
|
||||
pset_template=pset_template,
|
||||
)
|
||||
facet = Property(propertySet="Pset_WallCommon", name="Status", value="EXISTING", datatype="IfcLabel")
|
||||
facet = Property(propertySet="Pset_WallCommon", name="Status", value="EXISTING", datatype="IFCLABEL")
|
||||
run("Any matching value in an enumerated property will pass 1/3", facet=facet, inst=element, expected=True)
|
||||
facet = Property(propertySet="Pset_WallCommon", name="Status", value="DEMOLISH", datatype="IfcLabel")
|
||||
facet = Property(propertySet="Pset_WallCommon", name="Status", value="DEMOLISH", datatype="IFCLABEL")
|
||||
run("Any matching value in an enumerated property will pass 2/3", facet=facet, inst=element, expected=True)
|
||||
facet = Property(propertySet="Pset_WallCommon", name="Status", value="NEW", datatype="IfcLabel")
|
||||
facet = Property(propertySet="Pset_WallCommon", name="Status", value="NEW", datatype="IFCLABEL")
|
||||
run("Any matching value in an enumerated property will pass 3/3", facet=facet, inst=element, expected=False)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
@@ -1028,11 +1031,11 @@ class TestProperty:
|
||||
Name="Foo", ListValues=[ifc.createIfcLabel("X"), ifc.createIfcLabel("Y")]
|
||||
)
|
||||
pset.HasProperties = [list_property]
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="X", datatype="IfcLabel")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="X", datatype="IFCLABEL")
|
||||
run("Any matching value in a list property will pass 1/3", facet=facet, inst=element, expected=True)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="Y", datatype="IfcLabel")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="Y", datatype="IFCLABEL")
|
||||
run("Any matching value in a list property will pass 2/3", facet=facet, inst=element, expected=True)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="Z", datatype="IfcLabel")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="Z", datatype="IFCLABEL")
|
||||
run("Any matching value in a list property will pass 3/3", facet=facet, inst=element, expected=False)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
@@ -1045,13 +1048,13 @@ class TestProperty:
|
||||
SetPointValue=ifc.createIfcLengthMeasure(3000),
|
||||
)
|
||||
pset.HasProperties = [bounded_property]
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="1", datatype="IfcLengthMeasure")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="1", datatype="IFCLENGTHMEASURE")
|
||||
run("Any matching value in a bounded property will pass 1/4", facet=facet, inst=element, expected=True)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="5", datatype="IfcLengthMeasure")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="5", datatype="IFCLENGTHMEASURE")
|
||||
run("Any matching value in a bounded property will pass 2/4", facet=facet, inst=element, expected=True)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="3", datatype="IfcLengthMeasure")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="3", datatype="IFCLENGTHMEASURE")
|
||||
run("Any matching value in a bounded property will pass 3/4", facet=facet, inst=element, expected=True)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="2", datatype="IfcLengthMeasure")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="2", datatype="IFCLENGTHMEASURE")
|
||||
run("Any matching value in a bounded property will pass 4/4", facet=facet, inst=element, expected=False)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
@@ -1061,18 +1064,18 @@ class TestProperty:
|
||||
Name="Foo", DefiningValues=[ifc.createIfcLabel("X")], DefinedValues=[ifc.createIfcLengthMeasure(1000)]
|
||||
)
|
||||
pset.HasProperties = [table_property]
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="X", datatype="IfcLabel")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="X", datatype="IFCLABEL")
|
||||
run("Any matching value in a table property will pass 1/3", facet=facet, inst=element, expected=True)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="1", datatype="IfcLengthMeasure")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="1", datatype="IFCLENGTHMEASURE")
|
||||
run("Any matching value in a table property will pass 2/3", facet=facet, inst=element, expected=True)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="Y", datatype="IfcLabel")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="Y", datatype="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", datatype="IfcLabel")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="IFCLABEL")
|
||||
run("Reference properties are treated as objects and not supported", facet=facet, inst=element, expected=False)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
@@ -1091,21 +1094,21 @@ class TestProperty:
|
||||
RelatingPropertyDefinition=pset,
|
||||
)
|
||||
facet = Property(
|
||||
propertySet="Foo_Bar", name="PanelOperation", value="SWINGING", datatype="IfcDoorPanelOperationEnum"
|
||||
propertySet="Foo_Bar", name="PanelOperation", value="SWINGING", datatype="IFCDOORPANELOPERATIONENUM"
|
||||
)
|
||||
run("Predefined properties are supported but discouraged 1/2", facet=facet, inst=element, expected=True)
|
||||
facet = Property(
|
||||
propertySet="Foo_Bar", name="PanelOperation", value="SWONGING", datatype="IfcDoorPanelOperationEnum"
|
||||
propertySet="Foo_Bar", name="PanelOperation", value="SWONGING", datatype="IFCDOORPANELOPERATIONENUM"
|
||||
)
|
||||
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", datatype="IfcLengthMeasure")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="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")
|
||||
ifcopenshell.api.run("pset.edit_qto", ifc, qto=qto, properties={"Foo": ifc.createIfcLengthMeasure(42)})
|
||||
run("A name check will match any quantity with any value", facet=facet, inst=element, expected=True)
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="IfcAreaMeasure")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="IFCAREAMEASURE")
|
||||
run("Quantities must also match the appropriate measure", facet=facet, inst=element, expected=False)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
@@ -1114,9 +1117,9 @@ class TestProperty:
|
||||
complex_property = ifc.createIfcComplexProperty(Name="Foo", UsageName="RabbitAgilityTraining")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=complex_property, properties={"Rabbits": "Awesome"})
|
||||
pset.HasProperties = [complex_property]
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="IfcLabel")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="IFCLABEL")
|
||||
run("Complex properties are not supported 1/2", facet=facet, inst=element, expected=False)
|
||||
facet = Property(propertySet="Foo", name="Rabbits", datatype="IfcLabel")
|
||||
facet = Property(propertySet="Foo", name="Rabbits", datatype="IFCLABEL")
|
||||
run("Complex properties are not supported 2/2", facet=facet, inst=element, expected=False)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
@@ -1127,14 +1130,14 @@ class TestProperty:
|
||||
"pset.edit_qto", ifc, qto=complex_quantity, properties={"MyLength": ifc.createIfcLengthMeasure(42)}
|
||||
)
|
||||
qto.Quantities = [complex_quantity]
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="IfcLengthMeasure")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="IFCLENGTHMEASURE")
|
||||
run("Complex properties are not supported 1/2", facet=facet, inst=element, expected=False)
|
||||
facet = Property(propertySet="Foo", name="MyLength", datatype="IfcLengthMeasure")
|
||||
facet = Property(propertySet="Foo", name="MyLength", datatype="IFCLENGTHMEASURE")
|
||||
run("Complex properties are not supported 2/2", facet=facet, inst=element, expected=False)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
restriction = Restriction(options={"pattern": "Foo_.*"})
|
||||
facet = Property(propertySet=restriction, name="Foo", datatype="IfcLabel")
|
||||
facet = Property(propertySet=restriction, name="Foo", datatype="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")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Bar"})
|
||||
@@ -1147,7 +1150,7 @@ class TestProperty:
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
restriction = Restriction(options={"pattern": "Foo.*"})
|
||||
facet = Property(propertySet="Foo_Bar", name=restriction, value="x", datatype="IfcLabel")
|
||||
facet = Property(propertySet="Foo_Bar", name=restriction, value="x", datatype="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")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": "x"})
|
||||
@@ -1160,7 +1163,7 @@ class TestProperty:
|
||||
ifc = self.setup_ifc()
|
||||
restriction1 = Restriction(options={"pattern": "Foo.*"})
|
||||
restriction2 = Restriction(options={"enumeration": ["x", "y"]})
|
||||
facet = Property(propertySet="Foo_Bar", name=restriction1, value=restriction2, datatype="IfcLabel")
|
||||
facet = Property(propertySet="Foo_Bar", name=restriction1, value=restriction2, datatype="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")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foobar": "x", "Foobaz": "y"})
|
||||
@@ -1179,7 +1182,7 @@ class TestProperty:
|
||||
)
|
||||
|
||||
ifc = self.setup_ifc()
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="2", datatype="IfcTimeMeasure")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="2", datatype="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")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcMassMeasure(2)})
|
||||
@@ -1188,7 +1191,7 @@ class TestProperty:
|
||||
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", datatype="IfcLengthMeasure")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="2", datatype="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")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcLengthMeasure(2)})
|
||||
@@ -1212,7 +1215,7 @@ class TestProperty:
|
||||
ifcopenshell.api.run("type.assign_type", ifc, related_object=wall, relating_type=wall_type)
|
||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=wall_type, name="Foo_Bar")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Bar"})
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="IfcLabel")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", datatype="IFCLABEL")
|
||||
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)
|
||||
|
||||
@@ -1224,7 +1227,7 @@ class TestProperty:
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Baz"})
|
||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=wall, name="Foo_Bar")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": "Bar"})
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="Bar", datatype="IfcLabel")
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", value="Bar", datatype="IFCLABEL")
|
||||
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)
|
||||
|
||||
@@ -1243,7 +1246,7 @@ class TestProperty:
|
||||
class TestMaterial:
|
||||
def test_creating_a_material_facet(self):
|
||||
facet = Material()
|
||||
assert facet.asdict() == {}
|
||||
assert facet.asdict() == {"@maxOccurs": "unbounded"}
|
||||
facet = Material(
|
||||
value="value", uri="https://test.com", minOccurs="0", maxOccurs="unbounded", instructions="instructions"
|
||||
)
|
||||
@@ -1401,9 +1404,9 @@ class TestMaterial:
|
||||
class TestPartOf:
|
||||
def test_creating_a_partof_facet(self):
|
||||
facet = PartOf()
|
||||
assert facet.asdict() == {"entity": {"name": {"simpleValue": "IFCWALL"}}}
|
||||
assert facet.asdict() == {"entity": {"name": {"simpleValue": "IFCWALL"}}, "@maxOccurs": "unbounded" }
|
||||
facet = PartOf(
|
||||
entity="IfcGroup",
|
||||
entity="IFCGROUP",
|
||||
predefinedType="predefinedType",
|
||||
relation="IFCRELASSIGNSTOGROUP",
|
||||
minOccurs="0",
|
||||
@@ -1412,7 +1415,7 @@ class TestPartOf:
|
||||
)
|
||||
assert facet.asdict() == {
|
||||
"entity": {
|
||||
"name": {"simpleValue": "IfcGroup"},
|
||||
"name": {"simpleValue": "IFCGROUP"},
|
||||
"predefinedType": {"simpleValue": "predefinedType"},
|
||||
},
|
||||
"@relation": "IFCRELASSIGNSTOGROUP",
|
||||
|
||||
@@ -159,7 +159,7 @@ class TestIds:
|
||||
run("Prohibited specifications fail if at least one entity passes all requirements 1/3", specs, model, True)
|
||||
model = ifcopenshell.file()
|
||||
wall = model.createIfcWall(Name="Wally")
|
||||
run("Prohibited specifications fail if at least one entity passes all requirements 2/3", specs, model, True, [wall], [wall])
|
||||
run("Prohibited specifications fail if at least one entity passes all requirements 2/3", specs, model, False, [wall], [wall])
|
||||
model = ifcopenshell.file()
|
||||
wall = model.createIfcWall(Name="Waldo")
|
||||
run("Prohibited specifications fail if at least one entity passes all requirements 3/3", specs, model, False, [wall])
|
||||
|
||||
Reference in New Issue
Block a user