forked from developmentseed/titiler-stacapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_items.py
44 lines (34 loc) · 1.23 KB
/
test_items.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""Test titiler.stacapi Item endpoints."""
import json
import os
from unittest.mock import patch
import pystac
import pytest
from .conftest import mock_rasterio_open
item_json = os.path.join(
os.path.dirname(__file__), "fixtures", "20200307aC0853900w361030.json"
)
@patch("rio_tiler.io.rasterio.rasterio")
@patch("titiler.stacapi.dependencies.get_stac_item")
def test_stac_items(get_stac_item, rio, app):
"""test STAC items endpoints."""
rio.open = mock_rasterio_open
with open(item_json, "r") as f:
get_stac_item.return_value = pystac.Item.from_dict(json.loads(f.read()))
response = app.get(
"/collections/noaa-emergency-response/items/20200307aC0853900w361030/assets",
)
assert response.status_code == 200
assert response.json() == ["cog"]
with pytest.warns(UserWarning):
response = app.get(
"/collections/noaa-emergency-response/items/20200307aC0853900w361030/info",
)
assert response.status_code == 200
assert response.json()["cog"]
response = app.get(
"/collections/noaa-emergency-response/items/20200307aC0853900w361030/info",
params={"assets": "cog"},
)
assert response.status_code == 200
assert response.json()["cog"]