mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
fix issue with prohibited facets in 0065c5f, add a test
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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],
|
||||
[],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user