mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 06:39:13 +00:00
PartOf facet tests now give more granular reports on failing predefined type requirements
This commit is contained in:
@@ -436,6 +436,7 @@ class PartOf(Facet):
|
|||||||
"An element with an {relation} relationship",
|
"An element with an {relation} relationship",
|
||||||
]
|
]
|
||||||
self.requirement_templates = [
|
self.requirement_templates = [
|
||||||
|
"An element must have an {relation} relationship with an {name} of predefined type {predefinedType}",
|
||||||
"An element must have an {relation} relationship with an {name}",
|
"An element must have an {relation} relationship with an {name}",
|
||||||
"An element must have an {relation} relationship",
|
"An element must have an {relation} relationship",
|
||||||
]
|
]
|
||||||
@@ -478,10 +479,12 @@ class PartOf(Facet):
|
|||||||
ancestors = []
|
ancestors = []
|
||||||
parent = self.get_parent(inst)
|
parent = self.get_parent(inst)
|
||||||
while parent:
|
while parent:
|
||||||
ancestors.append(parent.is_a())
|
ancestors.append(parent.is_a().upper())
|
||||||
if parent.is_a().upper() == self.name:
|
if parent.is_a().upper() == self.name:
|
||||||
if self.predefinedType:
|
if self.predefinedType:
|
||||||
if ifcopenshell.util.element.get_predefined_type(parent) == self.predefinedType:
|
predefined_type = ifcopenshell.util.element.get_predefined_type(parent)
|
||||||
|
ancestors[-1] += f".{predefined_type}"
|
||||||
|
if predefined_type == self.predefinedType:
|
||||||
is_pass = True
|
is_pass = True
|
||||||
else:
|
else:
|
||||||
is_pass = True
|
is_pass = True
|
||||||
@@ -498,10 +501,12 @@ class PartOf(Facet):
|
|||||||
is_pass = False
|
is_pass = False
|
||||||
ancestors = []
|
ancestors = []
|
||||||
while aggregate is not None:
|
while aggregate is not None:
|
||||||
ancestors.append(aggregate.is_a())
|
ancestors.append(aggregate.is_a().upper())
|
||||||
if aggregate.is_a().upper() == self.name:
|
if aggregate.is_a().upper() == self.name:
|
||||||
if self.predefinedType:
|
if self.predefinedType:
|
||||||
if ifcopenshell.util.element.get_predefined_type(aggregate) == self.predefinedType:
|
predefined_type = ifcopenshell.util.element.get_predefined_type(aggregate)
|
||||||
|
ancestors[-1] += f".{predefined_type}"
|
||||||
|
if predefined_type == self.predefinedType:
|
||||||
is_pass = True
|
is_pass = True
|
||||||
else:
|
else:
|
||||||
is_pass = True
|
is_pass = True
|
||||||
@@ -536,7 +541,7 @@ class PartOf(Facet):
|
|||||||
if container.is_a().upper() != self.name:
|
if container.is_a().upper() != self.name:
|
||||||
is_pass = False
|
is_pass = False
|
||||||
reason = {"type": "ENTITY", "actual": container.is_a().upper()}
|
reason = {"type": "ENTITY", "actual": container.is_a().upper()}
|
||||||
if self.predefinedType:
|
if is_pass and self.predefinedType:
|
||||||
predefined_type = ifcopenshell.util.element.get_predefined_type(container)
|
predefined_type = ifcopenshell.util.element.get_predefined_type(container)
|
||||||
if predefined_type != self.predefinedType:
|
if predefined_type != self.predefinedType:
|
||||||
is_pass = False
|
is_pass = False
|
||||||
@@ -550,10 +555,12 @@ class PartOf(Facet):
|
|||||||
is_pass = False
|
is_pass = False
|
||||||
ancestors = []
|
ancestors = []
|
||||||
while nest is not None:
|
while nest is not None:
|
||||||
ancestors.append(nest.is_a())
|
ancestors.append(nest.is_a().upper())
|
||||||
if nest.is_a().upper() == self.name:
|
if nest.is_a().upper() == self.name:
|
||||||
if self.predefinedType:
|
if self.predefinedType:
|
||||||
if ifcopenshell.util.element.get_predefined_type(nest) == self.predefinedType:
|
predefined_type = ifcopenshell.util.element.get_predefined_type(nest)
|
||||||
|
ancestors[-1] += f".{predefined_type}"
|
||||||
|
if predefined_type == self.predefinedType:
|
||||||
is_pass = True
|
is_pass = True
|
||||||
else:
|
else:
|
||||||
is_pass = True
|
is_pass = True
|
||||||
@@ -573,15 +580,14 @@ class PartOf(Facet):
|
|||||||
if not is_pass:
|
if not is_pass:
|
||||||
reason = {"type": "NOVALUE"}
|
reason = {"type": "NOVALUE"}
|
||||||
if is_pass and self.name:
|
if is_pass and self.name:
|
||||||
is_pass = False
|
if building_element.is_a().upper() != self.name:
|
||||||
if building_element.is_a().upper() == self.name:
|
is_pass = False
|
||||||
if self.predefinedType:
|
reason = {"type": "ENTITY", "actual": building_element.is_a().upper()}
|
||||||
if ifcopenshell.util.element.get_predefined_type(building_element) == self.predefinedType:
|
if is_pass and self.predefinedType:
|
||||||
is_pass = True
|
predefined_type = ifcopenshell.util.element.get_predefined_type(building_element)
|
||||||
else:
|
if predefined_type != self.predefinedType:
|
||||||
is_pass = True
|
is_pass = False
|
||||||
if not is_pass:
|
reason = {"type": "PREDEFINEDTYPE", "actual": predefined_type}
|
||||||
reason = {"type": "ENTITY", "actual": building_element}
|
|
||||||
|
|
||||||
if self.cardinality == "prohibited":
|
if self.cardinality == "prohibited":
|
||||||
return PartOfResult(not is_pass, {"type": "PROHIBITED"})
|
return PartOfResult(not is_pass, {"type": "PROHIBITED"})
|
||||||
@@ -1086,11 +1092,11 @@ class AttributeResult(Result):
|
|||||||
elif self.reason["type"] == "FALSEY":
|
elif self.reason["type"] == "FALSEY":
|
||||||
return f"The attribute value \"{str(self.reason['actual'])}\" is empty"
|
return f"The attribute value \"{str(self.reason['actual'])}\" is empty"
|
||||||
elif self.reason["type"] == "INVALID":
|
elif self.reason["type"] == "INVALID":
|
||||||
return f"An invalid attribute name was specified in the IDS"
|
return "An invalid attribute name was specified in the IDS"
|
||||||
elif self.reason["type"] == "VALUE":
|
elif self.reason["type"] == "VALUE":
|
||||||
return f"The attribute value \"{str(self.reason['actual'])}\" does not match the requirement"
|
return f"The attribute value \"{str(self.reason['actual'])}\" does not match the requirement"
|
||||||
elif self.reason["type"] == "PROHIBITED":
|
elif self.reason["type"] == "PROHIBITED":
|
||||||
return f"The attribute value should not have met the requirement"
|
return "The attribute value should not have met the requirement"
|
||||||
|
|
||||||
|
|
||||||
class ClassificationResult(Result):
|
class ClassificationResult(Result):
|
||||||
@@ -1102,7 +1108,7 @@ class ClassificationResult(Result):
|
|||||||
elif self.reason["type"] == "SYSTEM":
|
elif self.reason["type"] == "SYSTEM":
|
||||||
return f"The systems \"{str(self.reason['actual'])}\" do not match the requirements"
|
return f"The systems \"{str(self.reason['actual'])}\" do not match the requirements"
|
||||||
elif self.reason["type"] == "PROHIBITED":
|
elif self.reason["type"] == "PROHIBITED":
|
||||||
return f"The classification should not have met the requirement"
|
return "The classification should not have met the requirement"
|
||||||
|
|
||||||
|
|
||||||
class PartOfResult(Result):
|
class PartOfResult(Result):
|
||||||
@@ -1111,8 +1117,10 @@ class PartOfResult(Result):
|
|||||||
return "The entity has no relationship"
|
return "The entity has no relationship"
|
||||||
elif self.reason["type"] == "ENTITY":
|
elif self.reason["type"] == "ENTITY":
|
||||||
return f"The entity has a relationship with incorrect entities: \"{str(self.reason['actual'])}\""
|
return f"The entity has a relationship with incorrect entities: \"{str(self.reason['actual'])}\""
|
||||||
|
elif self.reason["type"] == "PREDEFINEDTYPE":
|
||||||
|
return f"The entity has a relationship with incorrect predefined type: \"{str(self.reason['actual'])}\""
|
||||||
elif self.reason["type"] == "PROHIBITED":
|
elif self.reason["type"] == "PROHIBITED":
|
||||||
return f"The relationship should not have met the requirement"
|
return "The relationship should not have met the requirement"
|
||||||
|
|
||||||
|
|
||||||
class PropertyResult(Result):
|
class PropertyResult(Result):
|
||||||
|
|||||||
Reference in New Issue
Block a user