Skip to content

Commit

Permalink
Fix STAC-version dependent check for "collection-assets" in collectio…
Browse files Browse the repository at this point in the history
…n metadata #53
  • Loading branch information
soxofaan committed Aug 19, 2024
1 parent 136f453 commit 5b9727d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@


# 0.2.2

- Fix STAC-version dependent check for "collection-assets" (core) extension in collections assets test
([#53](https://github.com/Open-EO/openeo-test-suite/issues/53)).


# 0.2.1

- Include openeo-api and openeo-process project versions in report
([#50](https://github.com/Open-EO/openeo-test-suite/issues/50))
([#50](https://github.com/Open-EO/openeo-test-suite/issues/50)).
2 changes: 1 addition & 1 deletion src/openeo_test_suite/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.1"
__version__ = "0.2.2"
5 changes: 4 additions & 1 deletion src/openeo_test_suite/lib/collection_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,8 @@ def test_assets(self, collection):
"""
if "assets" in collection:
assert isinstance(collection["assets"], dict)
if collection["stac_version"].startswith("0."):

# Note: the "collection-assets" (core) extension is required per openEO spec for STAC < 1.0.0-rc.1,
# but it was only introduced by STAC 1.0.0-beta.1, so we actually just check for the two beta versions before rc.1:
if collection["stac_version"] in {"1.0.0-beta.1", "1.0.0-beta.2"}:
assert "collection-assets" in collection["stac_extensions"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import pytest

from openeo_test_suite.lib.collection_metadata import OpeneoApiCollectionTests


@pytest.mark.parametrize(
["stac_version", "extra_stac_extensions", "expect_success"],
[
("0.9.0", [], True),
("1.0.0-beta.1", [], False),
("1.0.0-beta.1", ["collection-assets"], True),
("1.0.0-beta.2", [], False),
("1.0.0-beta.2", ["collection-assets"], True),
("1.0.0-rc.1", [], True),
("1.0.0", [], True),
],
)
def test_collection_assets(stac_version, extra_stac_extensions, expect_success):
stac_extensions = [
"https://stac-extensions.github.io/datacube/v2.2.0/schema.json"
] + extra_stac_extensions
collection = {
"stac_version": stac_version,
"stac_extensions": stac_extensions,
"id": "S2",
"cube:dimensions": {},
"summaries": {},
"assets": {},
}
try:
OpeneoApiCollectionTests(collection)
success = True
except AssertionError:
success = False

assert success == expect_success

0 comments on commit 5b9727d

Please sign in to comment.