|
18 | 18 | import openeo |
19 | 19 | from openeo.capabilities import ApiVersionException |
20 | 20 | from openeo.internal.graph_building import FlatGraphableMixin, PGNode |
| 21 | +from openeo.metadata import TemporalDimension |
21 | 22 | from openeo.rest import ( |
22 | 23 | CapabilitiesException, |
23 | 24 | OpenEoApiError, |
|
40 | 41 | ) |
41 | 42 | from openeo.rest.vectorcube import VectorCube |
42 | 43 | from openeo.testing.stac import StacDummyBuilder |
43 | | -from openeo.util import ContextTimer, dict_no_none |
| 44 | +from openeo.util import ContextTimer, deep_get, dict_no_none |
44 | 45 |
|
45 | 46 | from .auth.test_cli import auth_config, refresh_token_store |
46 | 47 |
|
@@ -2622,6 +2623,34 @@ def test_load_stac_reduce_temporal(self, con120, tmp_path, temporal_dim): |
2622 | 2623 | }, |
2623 | 2624 | } |
2624 | 2625 |
|
| 2626 | + @pytest.mark.parametrize( |
| 2627 | + ["collection_extent", "dim_extent"], |
| 2628 | + [ |
| 2629 | + ( |
| 2630 | + {"spatial": {"bbox": [[3, 4, 5, 6]]}, "temporal": {"interval": [["2024-01-01", "2024-05-05"]]}}, |
| 2631 | + ["2024-01-01T00:00:00Z", "2024-05-05T00:00:00Z"], |
| 2632 | + ), |
| 2633 | + ( |
| 2634 | + {"spatial": {"bbox": [[3, 4, 5, 6]]}, "temporal": {"interval": [[None, "2024-05-05"]]}}, |
| 2635 | + [None, "2024-05-05T00:00:00Z"], |
| 2636 | + ), |
| 2637 | + ], |
| 2638 | + ) |
| 2639 | + def test_load_stac_no_cube_extension_temporal_dimension(self, con120, tmp_path, collection_extent, dim_extent): |
| 2640 | + """ |
| 2641 | + Metadata detection when STAC metadata does not use "cube" extension |
| 2642 | + https://github.com/Open-EO/openeo-python-client/issues/666 |
| 2643 | + """ |
| 2644 | + stac_path = tmp_path / "stac.json" |
| 2645 | + stac_data = StacDummyBuilder.collection(extent=collection_extent) |
| 2646 | + # No cube:dimensions, but at least "temporal" extent is set as indicator for having a temporal dimension |
| 2647 | + assert "cube:dimensions" not in stac_data |
| 2648 | + assert deep_get(stac_data, "extent", "temporal") |
| 2649 | + stac_path.write_text(json.dumps(stac_data)) |
| 2650 | + |
| 2651 | + cube = con120.load_stac(str(stac_path)) |
| 2652 | + assert cube.metadata.temporal_dimension == TemporalDimension(name="t", extent=dim_extent) |
| 2653 | + |
2625 | 2654 |
|
2626 | 2655 | @pytest.mark.parametrize( |
2627 | 2656 | "data", |
|
0 commit comments