|
10 | 10 | from contextlib import nullcontext
|
11 | 11 | from pathlib import Path
|
12 | 12 |
|
| 13 | +import dirty_equals |
13 | 14 | import pytest
|
14 | 15 | import requests
|
15 | 16 | import requests_mock
|
@@ -2703,6 +2704,31 @@ def test_load_collection_spatial_extent_vector_cube(self, dummy_backend):
|
2703 | 2704 | },
|
2704 | 2705 | }
|
2705 | 2706 |
|
| 2707 | + @pytest.mark.parametrize("crs", ["EPSG:4326", "epsg:4326", 4326, "4326"]) |
| 2708 | + def test_load_collection_normalize_epsg_crs(self, dummy_backend, crs, caplog): |
| 2709 | + caplog.set_level(level=logging.WARNING) |
| 2710 | + spatial_extent = {"west": 1, "south": 2, "east": 3, "north": 4, "crs": crs} |
| 2711 | + temporal_extent = ["2019-01-01", "2019-01-22"] |
| 2712 | + cube = dummy_backend.connection.load_collection( |
| 2713 | + "S2", spatial_extent=spatial_extent, temporal_extent=temporal_extent, bands=["B2", "B3"] |
| 2714 | + ) |
| 2715 | + cube.execute() |
| 2716 | + assert dummy_backend.get_sync_pg() == { |
| 2717 | + "loadcollection1": { |
| 2718 | + "process_id": "load_collection", |
| 2719 | + "arguments": { |
| 2720 | + "id": "S2", |
| 2721 | + "spatial_extent": {"east": 3, "north": 4, "south": 2, "west": 1, "crs": 4326}, |
| 2722 | + "temporal_extent": ["2019-01-01", "2019-01-22"], |
| 2723 | + "bands": ["B2", "B3"], |
| 2724 | + }, |
| 2725 | + "result": True, |
| 2726 | + } |
| 2727 | + } |
| 2728 | + if crs != 4326: |
| 2729 | + assert f"Normalized CRS {crs!r} to 4326" in caplog.text |
| 2730 | + else: |
| 2731 | + assert "Normalized CRS" not in caplog.text |
2706 | 2732 |
|
2707 | 2733 | def test_load_result(requests_mock):
|
2708 | 2734 | requests_mock.get(API_URL, json={"api_version": "1.0.0"})
|
@@ -3026,6 +3052,23 @@ def test_load_stac_spatial_extent_bbox(self, dummy_backend):
|
3026 | 3052 | "spatial_extent": {"west": 1, "south": 2, "east": 3, "north": 4},
|
3027 | 3053 | }
|
3028 | 3054 |
|
| 3055 | + @pytest.mark.parametrize("crs", ["EPSG:32632", "epsg:32632", 32632, "32632"]) |
| 3056 | + def test_load_stac_spatial_extent_bbox_normalize_epsg_crs(self, dummy_backend, crs, caplog): |
| 3057 | + caplog.set_level(level=logging.WARNING) |
| 3058 | + spatial_extent = {"west": 1, "south": 2, "east": 3, "north": 4, "crs": crs} |
| 3059 | + # TODO #694 how to avoid request to dummy STAC URL (without mocking, which is overkill for this test) |
| 3060 | + cube = dummy_backend.connection.load_stac("https://stac.test/data", spatial_extent=spatial_extent) |
| 3061 | + cube.execute() |
| 3062 | + assert dummy_backend.get_sync_pg()["loadstac1"]["arguments"] == { |
| 3063 | + "url": "https://stac.test/data", |
| 3064 | + "spatial_extent": {"west": 1, "south": 2, "east": 3, "north": 4, "crs": 32632}, |
| 3065 | + } |
| 3066 | + |
| 3067 | + if crs != 32632: |
| 3068 | + assert f"Normalized CRS {crs!r} to 32632" in caplog.text |
| 3069 | + else: |
| 3070 | + assert "Normalized CRS" not in caplog.text |
| 3071 | + |
3029 | 3072 | @pytest.mark.parametrize(
|
3030 | 3073 | "spatial_extent",
|
3031 | 3074 | [
|
|
0 commit comments