Skip to content

Commit 4c47eb5

Browse files
committed
Improve IDS static HTML reporter to report list of prohibited entities (they aren't passes or fails, just prohibited applicability)
1 parent 84d55d8 commit 4c47eb5

2 files changed

Lines changed: 63 additions & 1 deletion

File tree

src/ifctester/ifctester/reporter.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class ResultsSpecification(TypedDict):
8585
total_applicable: int
8686
total_applicable_pass: int
8787
total_applicable_fail: int
88+
applicable_entities: list[ResultsEntity]
8889
percent_applicable_pass: ResultsPercent
8990
total_checks: int
9091
total_checks_pass: int
@@ -383,6 +384,7 @@ def report_specification(self, specification: Specification) -> ResultsSpecifica
383384
total_applicable=total_applicable,
384385
total_applicable_pass=total_applicable_pass,
385386
total_applicable_fail=total_applicable - total_applicable_pass,
387+
applicable_entities=self.report_applicable_entities(specification),
386388
percent_applicable_pass=percent_applicable_pass,
387389
total_checks=total_checks,
388390
total_checks_pass=total_checks_pass,
@@ -393,6 +395,24 @@ def report_specification(self, specification: Specification) -> ResultsSpecifica
393395
requirements=requirements,
394396
)
395397

398+
def report_applicable_entities(self, specification: Specification) -> list[ResultsEntity]:
399+
return [
400+
ResultsEntity(
401+
{
402+
"element": e,
403+
"element_type": ifcopenshell.util.element.get_type(e),
404+
"class": e.is_a(),
405+
"predefined_type": ifcopenshell.util.element.get_predefined_type(e),
406+
"name": getattr(e, "Name", None),
407+
"description": getattr(e, "Description", None),
408+
"id": e.id(),
409+
"global_id": getattr(e, "GlobalId", None),
410+
"tag": getattr(e, "Tag", None),
411+
}
412+
)
413+
for e in specification.applicable_entities
414+
]
415+
396416
def report_passed_entities(self, requirement: Facet) -> list[ResultsEntity]:
397417
return [
398418
ResultsEntity(
@@ -459,6 +479,10 @@ def report(self) -> None:
459479
spec["is_prohibited"] = spec["cardinality"] == "prohibited"
460480
spec["cardinality"] = spec["cardinality"].capitalize()
461481
spec["has_requirements"] = bool(spec["requirements"])
482+
total_applicable_entities = len(spec["applicable_entities"])
483+
spec["applicable_entities"] = self.limit_entities(spec["applicable_entities"])
484+
spec["has_omitted_applicable"] = total_applicable_entities > self.entity_limit
485+
spec["total_omitted_applicable"] = total_applicable_entities - self.entity_limit
462486
for requirement in spec["requirements"]:
463487
total_passed_entities = len(requirement["passed_entities"])
464488
total_failed_entities = len(requirement["failed_entities"])

src/ifctester/ifctester/templates/report.html

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ <h2>{{name}}</h2>
152152
<p>
153153
<strong>Requirements</strong>
154154
</p>
155-
{{/has_requirements}}
156155
<ol>
157156
{{#requirements}}
158157
<li class="{{^total_checks}}skipped{{/total_checks}}{{#total_checks}}{{#status}}pass{{/status}}{{^status}}fail{{/status}}{{/total_checks}}">
@@ -252,6 +251,45 @@ <h2>{{name}}</h2>
252251
</li>
253252
{{/requirements}}
254253
</ol>
254+
{{/has_requirements}}
255+
{{#is_prohibited}}
256+
{{#total_applicable}}
257+
<table class="fail">
258+
<thead>
259+
<tr>
260+
<th>Class</th>
261+
<th>PredefinedType</th>
262+
<th>Name</th>
263+
<th>Description</th>
264+
<th>GlobalId</th>
265+
<th>Tag</th>
266+
</tr>
267+
</thead>
268+
<tbody>
269+
{{#applicable_entities}}
270+
<tr>
271+
<td>{{class}}</td>
272+
<td>{{predefined_type}}</td>
273+
<td>{{name}}</td>
274+
<td>{{description}}</td>
275+
<td>{{global_id}}</td>
276+
<td>{{tag}}</td>
277+
</tr>
278+
{{#extra_of_type}}
279+
<tr>
280+
<td colspan="7">... {{extra_of_type}} more of the same element type ({{type_name}} with Tag {{type_tag}} and GlobalId {{type_global_id}}) not shown ...</td>
281+
</tr>
282+
{{/extra_of_type}}
283+
{{/applicable_entities}}
284+
{{#has_omitted_applicable}}
285+
<tr>
286+
<td colspan="7"> ... {{total_omitted_applicable}} more failing elements not shown out of {{total_applicable}} total ...</td>
287+
</tr>
288+
{{/has_omitted_applicable}}
289+
</tbody>
290+
</table>
291+
{{/total_applicable}}
292+
{{/is_prohibited}}
255293
</div>
256294
</section>
257295
{{/specifications}}

0 commit comments

Comments
 (0)