Skip to content

Commit

Permalink
check version exist (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
malmans2 authored Dec 5, 2022
1 parent 030336e commit fc29a57
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions c3s_eqc_data_checker/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,15 @@ def check_cf_compliance(
silent=True,
)
for path in self.paths_iterator:
if version and version not in cfchecker.cfchecks.cfVersions:
versions = sorted(
str(version) for version in cfchecker.cfchecks.cfVersions
)
errors[
path
] = f"{version=!s} is not available.\nAvailable versions: {versions!r}."
continue

if self.files_format == "NETCDF":
inst.checker(path)
else:
Expand Down
6 changes: 6 additions & 0 deletions tests/test_20_grib.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ def test_cf_compliance(tmp_path: pathlib.Path, grib_path: pathlib.Path) -> None:
actual = checker.check_cf_compliance(None)
assert set(actual) == {str(tmp_path / "non-compliant.grib")}

actual = checker.check_cf_compliance("10")
print(actual.values)
assert actual[str(tmp_path / "non-compliant.grib")].startswith(
"version=CF-10 is not available."
)


def test_temporal_resolution(grib_path: pathlib.Path) -> None:
checker = Checker(str(grib_path / "GRIB2.tmpl"), files_format="GRIB")
Expand Down

0 comments on commit fc29a57

Please sign in to comment.