Skip to content

Commit

Permalink
use pytest instead
Browse files Browse the repository at this point in the history
  • Loading branch information
hrodmn committed Nov 21, 2024
1 parent 8cd702b commit de9edce
Showing 1 changed file with 32 additions and 39 deletions.
71 changes: 32 additions & 39 deletions tests/test_app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""test titiler-cmr app."""

import io
import warnings
from copy import deepcopy
from pathlib import Path
from typing import Tuple
Expand All @@ -10,7 +9,6 @@
from fastapi.testclient import TestClient
from httpx import Response
from PIL import Image
from rasterio.errors import NotGeoreferencedWarning

from titiler.cmr.timeseries import TimeseriesMediaType
from titiler.core.models.mapbox import TileJSON
Expand Down Expand Up @@ -101,6 +99,7 @@ def test_conformance(app):
assert "Conformance" in response.text


@pytest.mark.filterwarnings("ignore:rasterio.errors.NotGeoreferencedWarning")
@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"""
Expand All @@ -109,21 +108,18 @@ def test_rasterio_statistics(app, mock_cmr_get_assets, mn_geojson):
band = "Fmask"
datetime_range = "2024-10-09T00:00:01Z/2024-10-09T23:59:59Z"

with warnings.catch_warnings(record=True):
warnings.simplefilter("ignore", NotGeoreferencedWarning)

response = app.post(
"/statistics",
params={
"concept_id": concept_id,
"datetime": datetime_range,
"backend": "rasterio",
"bands_regex": band,
"bands": band,
"dst_crs": "epsg:32615",
},
json=mn_geojson,
)
response = app.post(
"/statistics",
params={
"concept_id": concept_id,
"datetime": datetime_range,
"backend": "rasterio",
"bands_regex": band,
"bands": band,
"dst_crs": "epsg:32615",
},
json=mn_geojson,
)

assert response.status_code == 200
assert response.headers["content-type"] == "application/geo+json"
Expand All @@ -138,28 +134,27 @@ def test_rasterio_statistics(app, mock_cmr_get_assets, mn_geojson):
assert round(stats[band]["count"]) == 273132


@pytest.mark.filterwarnings("ignore:rasterio.errors.NotGeoreferencedWarning")
@pytest.mark.vcr
def test_rasterio_feature(
app, mock_cmr_get_assets, rasterio_query_params, mn_geojson
) -> None:
"""Test /feature endpoint for rasterio backend"""
with warnings.catch_warnings(record=True):
warnings.simplefilter("ignore", NotGeoreferencedWarning)

response = app.post(
"/feature",
params={
**rasterio_query_params,
"format": "tif",
"width": 100,
"height": 100,
},
json=mn_geojson,
)
response = app.post(
"/feature",
params={
**rasterio_query_params,
"format": "tif",
"width": 100,
"height": 100,
},
json=mn_geojson,
)
assert response.status_code == 200
assert response.headers["content-type"] == "image/tiff; application=geotiff"


@pytest.mark.filterwarnings("ignore:rasterio.errors.NotGeoreferencedWarning")
@pytest.mark.vcr
def test_rasterio_part(
app,
Expand All @@ -169,15 +164,13 @@ def test_rasterio_part(
) -> None:
"""Test /part endpoint for rasterio backend"""

with warnings.catch_warnings(record=True):
warnings.simplefilter("ignore", NotGeoreferencedWarning)
response = app.get(
f"/bbox/{','.join(str(coord) for coord in mn_bounds)}/100x100.tif",
params={
**rasterio_query_params,
"format": "tif",
},
)
response = app.get(
f"/bbox/{','.join(str(coord) for coord in mn_bounds)}/100x100.tif",
params={
**rasterio_query_params,
"format": "tif",
},
)
assert response.status_code == 200
assert response.headers["content-type"] == "image/tiff; application=geotiff"

Expand Down

0 comments on commit de9edce

Please sign in to comment.