Skip to content

Commit

Permalink
First unit test on metadata_from_stac Open-EO#527
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentVerelst committed Mar 12, 2024
1 parent f6e8e4a commit ea41eaf
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from typing import List

import json
import pytest

from openeo.metadata import (
Expand All @@ -14,6 +15,7 @@
MetadataException,
SpatialDimension,
TemporalDimension,
metadata_from_stac,
)


Expand Down Expand Up @@ -782,3 +784,25 @@ def filter_bbox(self, bbox):
assert isinstance(new, MyCubeMetadata)
assert orig.bbox is None
assert new.bbox == (1, 2, 3, 4)


def test_metadata_from_stac(tmp_path):
collection_json = {
"type": "Collection",
"id": "test-collection",
"stac_version": "1.0.0",
"description": "Test collection",
"links": [],
"title": "Test Collection",
"extent": {
"spatial": {"bbox": [[-180.0, -90.0, 180.0, 90.0]]},
"temporal": {"interval": [["2020-01-01T00:00:00Z", "2020-01-10T00:00:00Z"]]},
},
"license": "proprietary",
"summaries": {"eo:bands": [{"name": "B01"}, {"name": "B02"}]},
}

path = tmp_path / "collection.json"
path.write_text(json.dumps(collection_json))
metadata = metadata_from_stac(path)
assert metadata.band_names == ["B01", "B02"]

0 comments on commit ea41eaf

Please sign in to comment.