|
6 | 6 | """
|
7 | 7 |
|
8 | 8 | import contextlib
|
| 9 | +import json |
9 | 10 | import pathlib
|
10 | 11 | import re
|
11 | 12 | from datetime import date, datetime
|
|
25 | 26 | from openeo.rest._testing import build_capabilities
|
26 | 27 | from openeo.rest.connection import Connection
|
27 | 28 | from openeo.rest.datacube import DataCube
|
| 29 | +from openeo.testing.stac import StacDummyBuilder |
28 | 30 | from openeo.util import dict_no_none
|
29 | 31 |
|
30 | 32 | from .. import get_download_graph
|
@@ -312,6 +314,41 @@ def test_load_stac_spatial_extent_parameter(self, dummy_backend):
|
312 | 314 | "spatial_extent": {"from_parameter": "zpatial_extent"},
|
313 | 315 | }
|
314 | 316 |
|
| 317 | + @pytest.mark.parametrize( |
| 318 | + "stac_metadata", |
| 319 | + [ |
| 320 | + StacDummyBuilder.item(), |
| 321 | + StacDummyBuilder.collection(), |
| 322 | + StacDummyBuilder.catalog(), |
| 323 | + ], |
| 324 | + ) |
| 325 | + def test_load_stac_resample_spatial(self, dummy_backend, tmp_path, stac_metadata): |
| 326 | + """https://github.com/Open-EO/openeo-python-client/issues/737""" |
| 327 | + stac_path = tmp_path / "stac.json" |
| 328 | + # TODO #738 real request mocking of STAC resources compatible with pystac? |
| 329 | + stac_path.write_text(json.dumps(stac_metadata)) |
| 330 | + cube = dummy_backend.connection.load_stac(str(stac_path)) |
| 331 | + cube = cube.resample_spatial(resolution=10, projection=4326) |
| 332 | + cube.execute() |
| 333 | + assert dummy_backend.get_sync_pg() == { |
| 334 | + "loadstac1": { |
| 335 | + "process_id": "load_stac", |
| 336 | + "arguments": {"url": dirty_equals.IsStr(regex=".*/stac.json")}, |
| 337 | + }, |
| 338 | + "resamplespatial1": { |
| 339 | + "process_id": "resample_spatial", |
| 340 | + "arguments": { |
| 341 | + "data": {"from_node": "loadstac1"}, |
| 342 | + "projection": 4326, |
| 343 | + "resolution": 10, |
| 344 | + "method": "near", |
| 345 | + "align": "upper-left", |
| 346 | + }, |
| 347 | + "result": True, |
| 348 | + }, |
| 349 | + } |
| 350 | + |
| 351 | + |
315 | 352 | def test_filter_temporal_basic_positional_args(s2cube):
|
316 | 353 | im = s2cube.filter_temporal("2016-01-01", "2016-03-10")
|
317 | 354 | graph = _get_leaf_node(im)
|
|
0 commit comments