Skip to content

Commit a0a15eb

Browse files
author
Kolea Plesco
committed
Updated coverage display for XPATH coverage report
1 parent 65605a1 commit a0a15eb

3 files changed

Lines changed: 23 additions & 9 deletions

File tree

ted_sws/notice_validator/adapters/xpath_coverage_runner.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,13 @@ def xpath_coverage(self, report: XPATHCoverageReport, notice_xpaths: XPATH_TYPE,
8181
report.xpath_covered = list(self.conceptual_xpaths & unique_notice_xpaths)
8282
report.xpath_not_covered = list(unique_notice_xpaths - self.conceptual_xpaths)
8383
report.xpath_extra = list(self.conceptual_xpaths - unique_notice_xpaths)
84-
if len(unique_notice_xpaths):
85-
report.coverage = len(report.xpath_covered) / len(unique_notice_xpaths)
84+
unique_notice_xpaths_len = len(unique_notice_xpaths)
85+
xpath_covered_len = len(report.xpath_covered)
86+
conceptual_xpaths_len = len(self.conceptual_xpaths)
87+
if unique_notice_xpaths_len:
88+
report.coverage = xpath_covered_len / unique_notice_xpaths_len
89+
if conceptual_xpaths_len:
90+
report.conceptual_coverage = xpath_covered_len / conceptual_xpaths_len
8691

8792
@classmethod
8893
def based_xpaths(cls, xpaths: List[str], base_xpath: str) -> List[str]:

ted_sws/notice_validator/model/coverage_report.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ class XPATHCoverageReport(PropertyBaseModel):
2626
xpath_not_covered: Optional[List[str]]
2727
xpath_extra: Optional[List[str]]
2828
coverage: Optional[float]
29+
conceptual_coverage: Optional[float]

ted_sws/notice_validator/resources/templates/xpath_coverage_report.jinja2

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,17 @@
7373
<ul>
7474
<li>Date created: {{ created_at }}</li>
7575
<li>Mapping suite identifier: {{ mapping_suite_id }}</li>
76-
<li>Coverage: <strong>{{ coverage }}</strong>
77-
<div><hr></div></li>
78-
<li>Notice identifier(s):
76+
<li>
77+
<div><hr></div>
78+
<h4>Overall coverage</h4>
79+
<h3>{{ "%.2f"|format((coverage|float * 100)) }}%</h3>
80+
<p>(Number of Conceptual XPATHs found in notices) / (Total number of unique XPATHs in provided notices)</p>
81+
<li><div><hr></div>
82+
<h4>Conceptual coverage</h4>
83+
<h3>{{ "%.2f"|format((conceptual_coverage|float * 100)) }}%</h3>
84+
<p>(Number of Conceptual XPATHs found in notices) / (Total number of unique Conceptual XPATHs)</p>
85+
</li>
86+
<li><div><hr></div>Notice identifier(s):
7987
<div data-role="collapsible" data-state="{% if notice_id|length > 1 %}collapsed{% endif %}"
8088
class="collapsible-wrapper">
8189
<h4><a href="#"></a></h4>
@@ -97,16 +105,17 @@
97105
<tr>
98106
<th>Title</th>
99107
<th>XPATH</th>
100-
<th>Count</th>
101-
<th>Notice</th>
102-
<th>Result</th>
108+
<th>Found</th>
109+
<th>Notice count</th>
110+
<th>Notices</th>
103111
</tr>
104112
</thead>
105113
<tbody>
106114
{% for item in xpath_assertions %}
107115
<tr>
108116
<td>{{ item.title }}</td>
109117
<td>{{ item.xpath }}</td>
118+
<td class="{% if item.query_result %}success{% else %}error{% endif %}">{{ item.query_result }}</td>
110119
<td>{{ item.count }}</td>
111120
<td class="notice-hit">{% if item.notice_hit %}
112121
<div data-role="collapsible" data-state="collapsed">
@@ -116,7 +125,6 @@
116125
</div>
117126
</div>
118127
{% endif %}</td>
119-
<td class="{% if item.query_result %}success{% else %}error{% endif %}">{{ item.query_result }}</td>
120128
</tr>
121129
{% endfor %}
122130
</tbody>

0 commit comments

Comments
 (0)