Skip to content

Commit

Permalink
updates xpath validator
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolea PLESCO authored and Kolea PLESCO committed Apr 8, 2024
1 parent b9cd039 commit 91fe65d
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def read_mapping_suite_xpaths(cls, mapping_suite: MappingSuite) -> List[MappingX
processed_xpaths = set()

for test_suite in mapping_suite.sparql_test_suites:
if test_suite != CONCEPTUAL_MAPPINGS_ASSERTIONS:
if test_suite.identifier != CONCEPTUAL_MAPPINGS_ASSERTIONS:
continue

for sparql_test in test_suite.sparql_tests:
Expand Down
4 changes: 2 additions & 2 deletions ted_sws/notice_validator/adapters/xpath_coverage_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def xpath_coverage_validation_report(self, notice: Notice) -> XPATHCoverageValid

xpaths: List[str] = []
for xpath in self.get_all_conceptual_xpaths():
if self.check_xpath_expression_with_xml(notice.xml_manifestation.object_data.encode("utf-8"), xpath):
if self.check_xpath_expression_with_xml(notice.xml_manifestation.object_data, xpath):
xpaths.append(xpath)
notice_xpaths: XPathDict = {notice.ted_id: xpaths}
self.validate_xpath_coverage_report(report, notice_xpaths, xpaths)
Expand Down Expand Up @@ -132,7 +132,7 @@ def xpath_coverage_validation_summary_report(
xpaths: List[str] = []
for xpath in self.get_all_conceptual_xpaths():
if self.check_xpath_expression_with_xml(
report_notice.notice.xml_manifestation.object_data.encode("utf-8"), xpath
report_notice.notice.xml_manifestation.object_data, xpath
):
xpaths.append(xpath)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#title: BT-701-notice BT-701-notice - BT-701-notice
#description: “BT-701-notice BT-701-notice - BT-701-notice” in SF corresponds to “BT-701 Notice Identifier” in eForms. The corresponding XML element is /*/cbc:ID[@schemeName='notice-id']. The expected ontology instances are epo: epo:Notice / epo:Indentifier / rdf:langString .
#xpath: /*/cbc:ID[@schemeName='notice-id']

PREFIX epo: <http://data.europa.eu/a4g/ontology#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

ASK WHERE {
?this rdf:type epo:Notice .
?this epo:hasID / epo:hasIdentifierValue ?value }
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#title: ND-ContractingParty ND-ContractingParty - ND-ContractingParty
#description: “ND-ContractingParty ND-ContractingParty - ND-ContractingParty” in SF corresponds to “nan nan” in eForms. The corresponding XML element is /*/cac:ContractingParty. The expected ontology instances are epo: epo:Notice / epo:AgentInRole (from CL1) .
#xpath: /*/cac:ContractingParty

PREFIX epo: <http://data.europa.eu/a4g/ontology#>
PREFIX epo-not: <http://data.europa.eu/a4g/ontology#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

ASK WHERE {
?this rdf:type epo:Notice .
?this epo-not:announcesRole ?value }
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#title: ND-ServiceProvider ND-ContractingParty.ND-ServiceProvider - ND-ServiceProvider
#description: “ND-ServiceProvider ND-ContractingParty.ND-ServiceProvider - ND-ServiceProvider” in SF corresponds to “nan nan” in eForms. The corresponding XML element is /*/cac:ContractingParty/cac:Party. The expected ontology instances are epo: org:Organization .
#xpath: /TED_EXPORT/FORM_SECTION/F03_2014/CONTRACTING_BODY/ADDRESS_CONTRACTING_BODY/OFFICIALNAME

PREFIX org: <http://www.w3.org/ns/org#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

ASK WHERE {
?this rdf:type org:Organization .
?this a org:Organization. }
1 change: 1 addition & 0 deletions tests/unit/notice_validator/test_xpath_coverage_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def test_xpath_coverage_runner(fake_notice_F03, fake_mapping_suite_F03_id, fake_
assert "mapping_suite_identifier" in json_report
assert "validation_result" in json_report
assert "xpath_assertions" in json_report["validation_result"]
assert "xpath_covered" in json_report["validation_result"]

assert xpath_coverage_html_report(report)

Expand Down

0 comments on commit 91fe65d

Please sign in to comment.