fix issue with prohibited facets in 0065c5f, add a test

This commit is contained in:
Andrej730
2024-04-01 13:49:42 +05:00
parent d8af8b58bb
commit 5c4c61bb15
2 changed files with 19 additions and 2 deletions
-2
View File
@@ -262,8 +262,6 @@ class Specification:
for facet in self.requirements:
result = facet(element)
is_pass = bool(result)
if facet.cardinality == "prohibited":
is_pass = not is_pass
if self.maxOccurs != 0: # This is a required or optional specification
if not is_pass:
self.failed_entities.add(element)
+19
View File
@@ -352,3 +352,22 @@ class TestSpecification:
None,
None,
)
def test_prohibited_facet(self):
specs = ids.Ids(title="Title")
spec = ids.Specification(name="Name")
spec.applicability.append(ids.Entity(name="IFCWALL"))
spec.requirements.append(ids.Attribute(name="Name", value="Waldo", cardinality="prohibited"))
specs.specifications.append(spec)
spec.set_usage("required")
model = ifcopenshell.file()
wall = model.createIfcWall(Name="Wally")
run(
"Prohibited facet not to fail if no entity passes it",
specs,
model,
True,
[wall],
[],
)