diff --git a/CHANGELOG.md b/CHANGELOG.md index 1082fe3..5242016 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)). diff --git a/src/openeo_test_suite/__init__.py b/src/openeo_test_suite/__init__.py index 3ced358..b5fdc75 100644 --- a/src/openeo_test_suite/__init__.py +++ b/src/openeo_test_suite/__init__.py @@ -1 +1 @@ -__version__ = "0.2.1" +__version__ = "0.2.2" diff --git a/src/openeo_test_suite/lib/collection_metadata.py b/src/openeo_test_suite/lib/collection_metadata.py index 8a67f40..ae117f5 100644 --- a/src/openeo_test_suite/lib/collection_metadata.py +++ b/src/openeo_test_suite/lib/collection_metadata.py @@ -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"] diff --git a/src/openeo_test_suite/lib/internal-tests/test_collection_metadata.py b/src/openeo_test_suite/lib/internal-tests/test_collection_metadata.py new file mode 100644 index 0000000..a328ade --- /dev/null +++ b/src/openeo_test_suite/lib/internal-tests/test_collection_metadata.py @@ -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