From 2027c71d991213bda4749d2ec1a5f39797e439bf Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 30 Sep 2025 00:07:14 +1000 Subject: [PATCH] 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. --- src/ifctester/ifctester/facet.py | 4 +++- src/ifctester/test/test_facet.py | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ifctester/ifctester/facet.py b/src/ifctester/ifctester/facet.py index a9498d5eb7..e2639b556c 100644 --- a/src/ifctester/ifctester/facet.py +++ b/src/ifctester/ifctester/facet.py @@ -688,7 +688,9 @@ class Property(Facet): elif prop is not None and prop != "": props[pset_name][self.baseName] = prop 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 self.cardinality == "optional": diff --git a/src/ifctester/test/test_facet.py b/src/ifctester/test/test_facet.py index 3daa2d213f..7bdb85bc01 100644 --- a/src/ifctester/test/test_facet.py +++ b/src/ifctester/test/test_facet.py @@ -921,8 +921,11 @@ class TestProperty: pset = ifcopenshell.api.pset.add_pset(ifc, product=element, name="Foo_Bar") 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) - 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) + 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"}) run("A name check will match any property with any string value", facet=facet, inst=element, expected=True)