Skip to content

Commit

Permalink
Working on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
abarciauskas-bgse committed Jun 4, 2024
1 parent ff72c2c commit 1aa53e0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest
import rasterio
from fastapi.testclient import TestClient
from rio_tiler.models import ImageData

DATA_DIR = os.path.join(os.path.dirname(__file__), "fixtures")

Expand All @@ -29,4 +30,5 @@ def mock_rasterio_open(asset):
"https://noaa-eri-pds.s3.us-east-1.amazonaws.com/2020_Nashville_Tornado/20200307a_RGB",
DATA_DIR,
)
import pdb; pdb.set_trace()
return rasterio.open(asset)
10 changes: 5 additions & 5 deletions tests/test_asset_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from titiler.stacapi.asset_reader import AssetReader
from titiler.stacapi.models import AssetInfo
from titiler.stacapi.xarray import XarrayReader

from .conftest import mock_rasterio_open

Expand All @@ -33,21 +32,22 @@ def test_get_reader_any():
assert empty_stac_reader._get_reader(asset_info) == Reader


@pytest.mark.xfail(reason="To be implemented.")
def test_get_reader_netcdf():
"""Test reader attribute is titiler.stacapi.XarrayReader"""
asset_info = AssetInfo(url="https://file.nc", type="application/netcdf")
empty_stac_reader = AssetReader({'bbox': [], 'assets': []})
assert empty_stac_reader._get_reader(asset_info) == XarrayReader

empty_stac_reader._get_reader(asset_info)

@pytest.mark.skip(reason="Too slow.")
@patch("rio_tiler.io.rasterio.rasterio")
def test_tile_cog(rio):
"""Test tile function with COG asset."""
rio.open = mock_rasterio_open

with AssetReader(item_json) as reader:
img = reader.tile(0, 0, 0, assets=["cog"])
assert type(img) == ImageData

assert isinstance(img, ImageData)

@pytest.mark.skip(reason="To be implemented.")
def test_tile_netcdf():
Expand Down
1 change: 0 additions & 1 deletion titiler/stacapi/asset_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ def tile( # noqa: C901
)

def _reader(asset: str, *args: Any, **kwargs: Any) -> ImageData:

asset_info = self._get_asset_info(asset)
reader = self._get_reader(asset_info)

Expand Down

0 comments on commit 1aa53e0

Please sign in to comment.