mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 22:33:33 +00:00
Fix #7164. Property facets with a restriction in the baseName would incorrectly test null values.
Our tests missed this detail. The previous test also did should_purge=True by default which doesn't property test for nullness.
This commit is contained in:
@@ -688,7 +688,9 @@ class Property(Facet):
|
|||||||
elif prop is not None and prop != "":
|
elif prop is not None and prop != "":
|
||||||
props[pset_name][self.baseName] = prop
|
props[pset_name][self.baseName] = prop
|
||||||
else:
|
else:
|
||||||
props[pset_name] = {k: v for k, v in pset_props.items() if k == self.baseName}
|
props[pset_name] = {
|
||||||
|
k: v for k, v in pset_props.items() if k == self.baseName and v is not None and v != ""
|
||||||
|
}
|
||||||
|
|
||||||
if not bool(props[pset_name]):
|
if not bool(props[pset_name]):
|
||||||
if self.cardinality == "optional":
|
if self.cardinality == "optional":
|
||||||
|
|||||||
@@ -921,8 +921,11 @@ class TestProperty:
|
|||||||
pset = ifcopenshell.api.pset.add_pset(ifc, product=element, name="Foo_Bar")
|
pset = ifcopenshell.api.pset.add_pset(ifc, product=element, name="Foo_Bar")
|
||||||
ifcopenshell.api.pset.edit_pset(ifc, pset=pset, properties={"AnotherProperty": "AnotherValue"})
|
ifcopenshell.api.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)
|
run("Elements with a matching pset but no property also fail", facet=facet, inst=element, expected=False)
|
||||||
ifcopenshell.api.pset.edit_pset(ifc, pset=pset, properties={"AnotherProperty": None})
|
ifcopenshell.api.pset.edit_pset(ifc, pset=pset, properties={"Foo": None}, should_purge=False)
|
||||||
run("Properties with a null value fail", facet=facet, inst=element, expected=False)
|
run("Properties with a null value fail", facet=facet, inst=element, expected=False)
|
||||||
|
restriction = Restriction(options={"pattern": "Fo.*"})
|
||||||
|
facet = Property(propertySet="Foo_Bar", baseName=restriction, dataType="IFCLABEL")
|
||||||
|
run("Pattern matched properties with a null value fail", facet=facet, inst=element, expected=False)
|
||||||
ifcopenshell.api.pset.edit_pset(ifc, pset=pset, properties={"Foo": "Bar"})
|
ifcopenshell.api.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)
|
run("A name check will match any property with any string value", facet=facet, inst=element, expected=True)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user