From b5a295111c012c005d69767b80a2f4dbd97d239d Mon Sep 17 00:00:00 2001 From: Alejandro Villar Date: Thu, 1 Aug 2024 10:40:15 +0200 Subject: [PATCH] Fix test reports not being written --- ogc/bblocks/validate.py | 2 +- ogc/bblocks/validation/__init__.py | 2 +- ogc/bblocks/validation/json_.py | 6 ++---- ogc/bblocks/validation/rdf.py | 6 ++---- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/ogc/bblocks/validate.py b/ogc/bblocks/validate.py index 9d5a837..87ca32c 100644 --- a/ogc/bblocks/validate.py +++ b/ogc/bblocks/validate.py @@ -185,7 +185,7 @@ def _validate_resource(bblock: BuildingBlock, base_uri=base_uri, additional_shacl_closures=additional_shacl_closures, schema_ref=schema_ref) - any_validator_run = any_validator_run or (result is not None) + any_validator_run = any_validator_run or (result is not False) except Exception as unknown_exc: report.add_entry(ValidationReportEntry( diff --git a/ogc/bblocks/validation/__init__.py b/ogc/bblocks/validation/__init__.py index 38d448b..a87d5ac 100644 --- a/ogc/bblocks/validation/__init__.py +++ b/ogc/bblocks/validation/__init__.py @@ -23,7 +23,7 @@ def validate(self, filename: Path, output_filename: Path, base_uri: str | None = None, resource_url: str | None = None, require_fail: bool | None = None, - **kwargs) -> ValidationReportItem | None: + **kwargs) -> bool | None: raise NotImplementedError diff --git a/ogc/bblocks/validation/json_.py b/ogc/bblocks/validation/json_.py index 37342d9..a5f7388 100644 --- a/ogc/bblocks/validation/json_.py +++ b/ogc/bblocks/validation/json_.py @@ -88,10 +88,10 @@ def __init__(self, bblock: BuildingBlock, register: BuildingBlockRegister): def validate(self, filename: Path, output_filename: Path, report: ValidationReportItem, contents: str | None = None, schema_ref: str | None = None, - **kwargs) -> ValidationReportItem | None: + **kwargs) -> bool | None: if filename.suffix not in ('.json', '.jsonld', '.yaml', '.yml'): - return + return False file_from = 'examples' if report.source.type == ValidationItemSourceType.EXAMPLE else 'test resources' @@ -232,5 +232,3 @@ def validate(self, filename: Path, output_filename: Path, report: ValidationRepo 'col': e.colno, } )) - - return report diff --git a/ogc/bblocks/validation/rdf.py b/ogc/bblocks/validation/rdf.py index 127f9ac..74ab399 100644 --- a/ogc/bblocks/validation/rdf.py +++ b/ogc/bblocks/validation/rdf.py @@ -269,11 +269,11 @@ def validate(self, filename: Path, output_filename: Path, report: ValidationRepo contents: str | None = None, base_uri: str | None = None, additional_shacl_closures: list[str | Path] | None = None, - **kwargs) -> ValidationReportItem | None: + **kwargs) -> bool | None: graph = self._load_graph(filename, output_filename, report, contents, base_uri) if graph is None: - return + return False if graph is not None and (contents or filename.suffix != '.ttl'): try: @@ -418,5 +418,3 @@ def validate(self, filename: Path, output_filename: Path, report: ValidationRepo 'shaclFile': str(shacl_file), } )) - - return report