Skip to content

Commit

Permalink
Merge pull request #202 from tschaub/failure-detail
Browse files Browse the repository at this point in the history
Include detail about failing item in message
  • Loading branch information
jonhealy1 authored Mar 15, 2022
2 parents c1b4a72 + 05a291f commit e42fb33
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/)
### Fixed

- Reordered exception handlers to avoid unreachable code
- Details about invalid items is shown in the message when in recursive mode

## [v3.0.0] - 2022-03-11

Expand Down Expand Up @@ -140,7 +141,10 @@ The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/)
- Logging. Various additions were made here depending on the options selected. This was done to help assist people to update their STAC collections.

[v3.0.0]: <https://github.com/sparkgeo/stac-validator/compare/v2.5.0..main>
[v2.5.0]: <https://github.com/sparkgeo/stac-validator/compare/v2.4.0..v2.5.0>
[v2.5.0]: <https://github.com/sparkgeo/stac-validator/compare/v2.4.3..v2.5.0>
[v2.4.3]: <https://github.com/sparkgeo/stac-validator/compare/v2.3.0..v2.4.0>
[v2.4.2]: <https://github.com/sparkgeo/stac-validator/compare/v2.4.1..v2.4.2>
[v2.4.1]: <https://github.com/sparkgeo/stac-validator/compare/v2.4.0..v2.4.1>
[v2.4.0]: <https://github.com/sparkgeo/stac-validator/compare/v2.3.0..v2.4.0>
[v2.3.0]: <https://github.com/sparkgeo/stac-validator/compare/v2.2.0..v2.3.0>
[v2.2.0]: <https://github.com/sparkgeo/stac-validator/compare/v2.1.0..v2.2.0>
Expand Down
5 changes: 2 additions & 3 deletions stac_validator/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,8 @@ def run(cls):
except Exception as e:
message.update(cls.create_err_msg("Exception", str(e)))

message["valid_stac"] = cls.valid

if not cls.recursive:
if len(message) > 0:
message["valid_stac"] = cls.valid
cls.message.append(message)

if cls.log != "":
Expand Down
29 changes: 29 additions & 0 deletions tests/test_recursion.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,32 @@ def test_recursion_without_max_depth():
stac = stac_validator.StacValidate(stac_file, recursive=True)
stac.run()
assert len(stac.message) == 6


def test_recursion_with_bad_item():
stac_file = "tests/test_data/v100/catalog-with-bad-item.json"
stac = stac_validator.StacValidate(stac_file, recursive=True)
stac.run()
assert len(stac.message) == 2
assert stac.message == [
{
"version": "1.0.0",
"path": "tests/test_data/v100/catalog-with-bad-item.json",
"schema": [
"https://schemas.stacspec.org/v1.0.0/catalog-spec/json-schema/catalog.json"
],
"valid_stac": True,
"asset_type": "CATALOG",
"validation_method": "recursive",
},
{
"version": "1.0.0",
"path": "tests/test_data/v100/./bad-item.json",
"schema": [
"https://schemas.stacspec.org/v1.0.0/item-spec/json-schema/item.json"
],
"valid_stac": False,
"error_type": "ValidationError",
"error_message": "'id' is a required property of the root of the STAC object",
},
]

0 comments on commit e42fb33

Please sign in to comment.