mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 06:21:40 +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:
|
for facet in self.requirements:
|
||||||
result = facet(element)
|
result = facet(element)
|
||||||
is_pass = bool(result)
|
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 self.maxOccurs != 0: # This is a required or optional specification
|
||||||
if not is_pass:
|
if not is_pass:
|
||||||
self.failed_entities.add(element)
|
self.failed_entities.add(element)
|
||||||
|
|||||||
@@ -352,3 +352,22 @@ class TestSpecification:
|
|||||||
None,
|
None,
|
||||||
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