Skip to content

Commit fc06ac3

Browse files
committed
--wip-- [skip ci]
1 parent 3db04da commit fc06ac3

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

stac_fastapi/pgstac/tests/api/test_api.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
from datetime import datetime, timedelta
2-
from urllib.parse import quote_plus
2+
from urllib.parse import quote_plus, urljoin
33

4+
import attrs
45
import orjson
56
import pytest
7+
from httpx import AsyncClient
8+
9+
from stac_fastapi.pgstac.db import close_db_connection, connect_to_db, dbfunc
10+
from stac_fastapi.types.stac import Collection
611

712
STAC_CORE_ROUTES = [
813
"GET /",
@@ -92,6 +97,39 @@ async def test_core_router(api_client, app):
9297
assert not core_routes - api_routes
9398

9499

100+
async def test_response_models(api_client):
101+
settings = api_client.settings
102+
settings.enable_response_models = True
103+
api = attrs.evolve(api_client, settings=settings)
104+
await connect_to_db(api.app)
105+
106+
base_url = "http://test"
107+
if api.app.state.router_prefix != "":
108+
base_url = urljoin(base_url, api.app.state.router_prefix)
109+
110+
collection = Collection(
111+
type="MyCollection",
112+
stac_version="1.0.0",
113+
id="my-collection",
114+
description="A test collection with an invalid type field",
115+
links=[],
116+
keywords=[],
117+
license="proprietary",
118+
providers=[],
119+
extent={},
120+
summaries={},
121+
assets={},
122+
)
123+
pool = api.app.state.writepool
124+
await dbfunc(pool, "create_collection", collection)
125+
126+
async with AsyncClient(app=api.app, base_url=base_url) as client:
127+
response = await client.get("/collections/my-collection")
128+
assert response.status_code == 500, response.json()["type"]
129+
130+
await close_db_connection(api.app)
131+
132+
95133
async def test_landing_page_stac_extensions(app_client):
96134
resp = await app_client.get("/")
97135
assert resp.status_code == 200

0 commit comments

Comments
 (0)