Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit de2bd3f

Browse files
committed
Fix #6914. Bug where HTML IDS report did not visually indicate prohibited results correctly.
1 parent cfa21b3 commit de2bd3f

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

src/ifctester/ifctester/ids.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def validate(self, ifc_file: ifcopenshell.file, should_filter_version: bool = Fa
328328
for facet in self.requirements:
329329
facet.status = False
330330
elif self.maxOccurs == 0: # Prohibited specification
331-
if self.applicable_entities and not self.requirements:
331+
if self.applicable_entities:
332332
self.status = False
333333

334334
def get_usage(self) -> Cardinality:

src/ifctester/ifctester/reporter.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class ResultsSpecification(TypedDict):
8686
total_checks_pass: int
8787
total_checks_fail: int
8888
percent_checks_pass: ResultsPercent
89-
required: bool
89+
cardinality: str
9090
applicability: list[str]
9191
requirements: list[ResultsRequirement]
9292

@@ -356,6 +356,13 @@ def report_specification(self, specification: Specification) -> ResultsSpecifica
356356
)
357357
percent_checks_pass = math.floor((total_checks_pass / total_checks) * 100) if total_checks else "N/A"
358358

359+
if specification.minOccurs == 1 and specification.maxOccurs == "unbounded":
360+
cardinality = "required"
361+
elif specification.minOccurs == 0 and specification.maxOccurs == "unbounded":
362+
cardinality = "optional"
363+
elif specification.minOccurs == 0 and specification.maxOccurs == 0:
364+
cardinality = "prohibited"
365+
359366
return ResultsSpecification(
360367
name=specification.name,
361368
description=specification.description,
@@ -370,7 +377,7 @@ def report_specification(self, specification: Specification) -> ResultsSpecifica
370377
total_checks_pass=total_checks_pass,
371378
total_checks_fail=total_checks - total_checks_pass,
372379
percent_checks_pass=percent_checks_pass,
373-
required=specification.minOccurs != 0,
380+
cardinality=cardinality,
374381
applicability=applicability,
375382
requirements=requirements,
376383
)
@@ -435,6 +442,12 @@ def __init__(self, ids: Ids):
435442
def report(self) -> None:
436443
super().report()
437444
for spec in self.results["specifications"]:
445+
print('checking', spec["cardinality"])
446+
if spec["cardinality"] == "optional" and spec["total_checks"] == 0:
447+
spec["is_skipped"] = True
448+
spec["is_prohibited"] = spec["cardinality"] == "prohibited"
449+
spec["cardinality"] = spec["cardinality"].capitalize()
450+
spec["has_requirements"] = bool(spec["requirements"])
438451
for requirement in spec["requirements"]:
439452
total_passed_entities = len(requirement["passed_entities"])
440453
total_failed_entities = len(requirement["failed_entities"])

src/ifctester/ifctester/templates/report.html

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,26 @@ <h2>{{name}}</h2>
107107
{{/instructions}}
108108

109109
<div class="container">
110-
<div class="{{^total_checks}}skipped{{/total_checks}}{{#total_checks}}{{#status}}pass{{/status}}{{^status}}fail{{/status}}{{/total_checks}} percent" style="width: {{^total_checks}}100{{/total_checks}}{{#total_checks}}{{percent_checks_pass}}{{/total_checks}}%;">{{^total_checks}}Skipped{{/total_checks}}{{#total_checks}}{{percent_checks_pass}}%{{/total_checks}}</div>
110+
<div class="
111+
{{#is_skipped}}skipped{{/is_skipped}}
112+
{{^is_skipped}}{{#status}}pass{{/status}}{{^status}}fail{{/status}}{{/is_skipped}}
113+
percent" style="width: {{^total_checks}}100{{/total_checks}}{{#total_checks}}{{percent_checks_pass}}{{/total_checks}}%;">{{#is_skipped}}Skipped{{/is_skipped}}{{^is_skipped}}{{percent_checks_pass}}%{{/is_skipped}}</div>
111114
</div>
112115
<p>
113-
<span class="item {{^total_checks}}skipped{{/total_checks}}{{#total_checks}}{{#status}}pass{{/status}}{{^status}}fail{{/status}}{{/total_checks}}">{{^total_checks}}Skipped{{/total_checks}}{{#total_checks}}{{#status}}Pass{{/status}}{{^status}}Fail{{/status}}{{/total_checks}}</span>
116+
<span class="item {{#is_skipped}}skipped{{/is_skipped}}{{^is_skipped}}{{#status}}pass{{/status}}{{^status}}fail{{/status}}{{/is_skipped}}">{{#is_skipped}}Optional: Skipped{{/is_skipped}}{{^is_skipped}}{{#status}}{{cardinality}}: Pass{{/status}}{{^status}}{{cardinality}}: Fail{{/status}}{{/is_skipped}}</span>
117+
{{#is_prohibited}}
118+
<span class="item">
119+
Elements matched: <strong>{{total_applicable}}</strong>
120+
</span>
121+
{{/is_prohibited}}
122+
{{^is_prohibited}}
114123
<span class="item">
115124
Checks passed: <strong>{{total_checks_pass}}</strong> / <strong>{{total_checks}}</strong>
116125
</span>
117126
<span class="item">
118127
Elements passed: <strong>{{total_applicable_pass}}</strong> / <strong>{{total_applicable}}</strong>
119128
</span>
129+
{{/is_prohibited}}
120130
</p>
121131
{{^is_ifc_version}}
122132
<p>
@@ -135,9 +145,11 @@ <h2>{{name}}</h2>
135145
<li>{{.}}</li>
136146
{{/applicability}}
137147
</ul>
148+
{{#has_requirements}}
138149
<p>
139150
<strong>Requirements</strong>
140151
</p>
152+
{{/has_requirements}}
141153
<ol>
142154
{{#requirements}}
143155
<li class="{{^total_checks}}skipped{{/total_checks}}{{#total_checks}}{{#status}}pass{{/status}}{{^status}}fail{{/status}}{{/total_checks}}">

0 commit comments

Comments
 (0)