Skip to content

Commit

Permalink
Merge pull request #302 from OP-TED/feature/TED-764
Browse files Browse the repository at this point in the history
Feature/ted 764
  • Loading branch information
CaptainOfHacks authored Oct 11, 2022
2 parents 4e96698 + 301d396 commit 746fca3
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def mapping_suite_read_conceptual_mapping(conceptual_mappings_file_path: Path) -
conceptual_mapping.rml_modules = _read_conceptual_mapping_rml_modules(
dfs[CONCEPTUAL_MAPPINGS_RML_MODULES_SHEET_NAME])
conceptual_mapping.xpaths = _read_conceptual_mapping_xpaths(
rules_df=dfs[CONCEPTUAL_MAPPINGS_RULES_SHEET_NAME],
rules_df=dfs[CONCEPTUAL_MAPPINGS_RULES_SHEET_NAME][1:].copy(),
base_xpath=metadata.base_xpath
)

Expand Down
8 changes: 4 additions & 4 deletions ted_sws/notice_validator/adapters/xpath_coverage_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def xpath_assertions(self, notice_xpaths: XPATH_TYPE,
xpath_assertion.notice_hit = self.find_notice_by_xpath(notice_xpaths, xpath)
xpath_assertion.query_result = xpath_assertion.count > 0
xpath_assertions.append(xpath_assertion)
return xpath_assertions
return sorted(xpath_assertions, key=lambda x: x.form_field)

def validate_xpath_coverage_report(self, report: XPATHCoverageValidationReport, notice_xpaths: XPATH_TYPE,
xpaths_list: List[str], notice_id: List[str]):
Expand All @@ -82,9 +82,9 @@ def validate_xpath_coverage_report(self, report: XPATHCoverageValidationReport,
validation_result: XPATHCoverageValidationResult = XPATHCoverageValidationResult()
validation_result.notice_id = notice_id
validation_result.xpath_assertions = self.xpath_assertions(notice_xpaths, xpaths_list)
validation_result.xpath_covered = list(self.conceptual_xpaths & unique_notice_xpaths)
validation_result.xpath_not_covered = list(unique_notice_xpaths - self.conceptual_xpaths)
validation_result.xpath_extra = list(self.conceptual_xpaths - unique_notice_xpaths)
validation_result.xpath_covered = sorted(list(self.conceptual_xpaths & unique_notice_xpaths))
validation_result.xpath_not_covered = sorted(list(unique_notice_xpaths - self.conceptual_xpaths))
validation_result.xpath_extra = sorted(list(self.conceptual_xpaths - unique_notice_xpaths))
unique_notice_xpaths_len = len(unique_notice_xpaths)
xpath_covered_len = len(validation_result.xpath_covered)
conceptual_xpaths_len = len(self.conceptual_xpaths)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<hr>
<h2>Extended results</h2>
<h1>{{ validation_results.identifier }}</h1>
<table class="display">
<table class="display" data-order='[[0, "asc"]]'>
<thead class="center aligned">
<tr>
<th>focusNode</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
</table>
<hr>
<h2>Results</h2>
<table class="display">
<table class="display" data-order='[[0, "asc"]]'>
<thead class="center aligned">
<tr>
<th>Form Field</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
{% if validation_result.xpath_assertions|length > 0 %}
<hr>
<h2>XPATH Assertions</h2>
<table class="display" data-order='[[3, "asc"]]'>
<table class="display" data-order='[[0, "asc"]]'>
<thead>
<tr>
<th>Form Field</th>
Expand Down
9 changes: 8 additions & 1 deletion ted_sws/notice_validator/services/shacl_test_suite_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ def execute_test_suite(self) -> SHACLTestSuiteValidationReport:
shacl_shape_validation_result.results_dict = json.loads(
result_graph.query(shacl_shape_result_query).serialize(
format='json').decode("UTF-8"))

if (shacl_shape_validation_result.results_dict
and shacl_shape_validation_result.results_dict["results"]
and shacl_shape_validation_result.results_dict["results"]["bindings"]):
shacl_shape_validation_result.results_dict["results"]["bindings"].sort(
key=lambda x: x["focusNode"]["value"])

except Exception as e:
shacl_shape_validation_result.error = str(e)[:100]

Expand Down Expand Up @@ -80,7 +87,7 @@ def shacl_validation(rdf_manifestation: RDFManifestation) -> List[SHACLTestSuite
mapping_suite=mapping_suite_package).execute_test_suite()
reports.append(generate_shacl_report(shacl_test_suite_execution=test_suite_execution))

return reports
return sorted(reports, key=lambda x: x.test_suite_identifier)

for report in shacl_validation(rdf_manifestation=notice.rdf_manifestation):
notice.set_rdf_validation(rdf_validation=report)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ def execute_test_suite(self) -> SPARQLTestSuiteValidationReport:
sparql_query_result.error = str(e)[:100]
sparql_query_result.result = SPARQLQueryRefinedResultType.ERROR
test_suite_executions.validation_results.append(sparql_query_result)

test_suite_executions.validation_results.sort(key=lambda x: x.query.title)
return test_suite_executions


Expand Down Expand Up @@ -152,7 +154,7 @@ def sparql_validation(rdf_manifestation: RDFManifestation) -> List[SPARQLTestSui
mapping_suite=mapping_suite_package).execute_test_suite()
report_builder = SPARQLReportBuilder(sparql_test_suite_execution=test_suite_execution)
reports.append(report_builder.generate_report())
return reports
return sorted(reports, key=lambda x: x.test_suite_identifier)

for report in sparql_validation(rdf_manifestation=notice.rdf_manifestation):
notice.set_rdf_validation(rdf_validation=report)
Expand Down

0 comments on commit 746fca3

Please sign in to comment.