From a3ebbbfc901a16b0c3c0ea8e7a9f79721b5548d4 Mon Sep 17 00:00:00 2001 From: hrodmn Date: Tue, 26 Nov 2024 13:48:27 -0600 Subject: [PATCH 1/2] add tilejson tests --- tests/test_app.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/test_app.py b/tests/test_app.py index 607d526..02c0f49 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -101,6 +101,22 @@ def test_conformance(app): assert "Conformance" in response.text +@pytest.mark.vcr +def test_rasterio_tilejson(app, rasterio_query_params): + """Test /tilejson.json endpoint for rasterio backend""" + + response = app.get( + "/WebMercatorQuad/tilejson.json", + params={ + **rasterio_query_params, + "datetime": "2024-10-11T00:00:00Z/2024-10-12T23:59:59Z", + }, + ) + + assert response.status_code == 200 + assert response.headers["content-type"] == "application/json" + + @pytest.mark.vcr def test_rasterio_statistics(app, mock_cmr_get_assets, mn_geojson): """Test /statistics endpoint for a polygon that straddles the boundary between two HLS granules""" @@ -182,6 +198,22 @@ def test_rasterio_part( assert response.headers["content-type"] == "image/tiff; application=geotiff" +@pytest.mark.vcr +def test_xarray_tilejson(app, xarray_query_params): + """Test /tilejson.json endpoint for xarray backend""" + + response = app.get( + "/WebMercatorQuad/tilejson.json", + params={ + **xarray_query_params, + "datetime": "2024-10-11T00:00:00Z/2024-10-12T23:59:59Z", + }, + ) + + assert response.status_code == 200 + assert response.headers["content-type"] == "application/json" + + @pytest.mark.vcr def test_xarray_statistics( app, mock_cmr_get_assets, xarray_query_params, arctic_geojson From a2fef269eabdab7d26d680f138d307e28b49b2eb Mon Sep 17 00:00:00 2001 From: hrodmn Date: Tue, 26 Nov 2024 13:49:03 -0600 Subject: [PATCH 2/2] fix tilejson endpoint --- tests/test_app.py | 6 ++++++ titiler/cmr/factory.py | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test_app.py b/tests/test_app.py index 02c0f49..1bdfeae 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -116,6 +116,9 @@ def test_rasterio_tilejson(app, rasterio_query_params): assert response.status_code == 200 assert response.headers["content-type"] == "application/json" + tilejson = response.json() + assert tilejson["bounds"] == [-180.0, -90.0, 180.0, 90.0] + @pytest.mark.vcr def test_rasterio_statistics(app, mock_cmr_get_assets, mn_geojson): @@ -213,6 +216,9 @@ def test_xarray_tilejson(app, xarray_query_params): assert response.status_code == 200 assert response.headers["content-type"] == "application/json" + tilejson = response.json() + assert tilejson["bounds"] == [-180.0, -90.0, 180.0, 90.0] + @pytest.mark.vcr def test_xarray_statistics( diff --git a/titiler/cmr/factory.py b/titiler/cmr/factory.py index 7f6b819..6781877 100644 --- a/titiler/cmr/factory.py +++ b/titiler/cmr/factory.py @@ -636,7 +636,8 @@ def tilejson_endpoint( # type: ignore auth=request.app.state.cmr_auth, ) as src_dst: minx, miny, maxx, maxy = zip( - [-180, -90, 180, 90], list(src_dst.geographic_bounds) + [-180, -90, 180, 90], + src_dst.get_geographic_bounds(crs=src_dst.geographic_crs), ) bounds = [max(minx), max(miny), min(maxx), min(maxy)]