Skip to content

Commit bf66caf

Browse files
committed
add test for additional extensions with collection-search
1 parent 693a204 commit bf66caf

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

tests/api/test_api.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,22 @@ async def test_get_collections_search(
528528
)
529529
assert len(resp.json()["collections"]) == 2
530530

531+
# this search should return test collection 1 first
532+
resp = await app_client.get(
533+
"/collections",
534+
params={"sortby": "title"},
535+
)
536+
assert resp.json()["collections"][0]["id"] == load_test_collection["id"]
537+
assert resp.json()["collections"][1]["id"] == load_test2_collection.id
538+
539+
# this search should return test collection 2 first
540+
resp = await app_client.get(
541+
"/collections",
542+
params={"sortby": "-title"},
543+
)
544+
assert resp.json()["collections"][1]["id"] == load_test_collection["id"]
545+
assert resp.json()["collections"][0]["id"] == load_test2_collection.id
546+
531547

532548
@pytest.mark.asyncio
533549
async def test_item_collection_filter_bbox(

tests/conftest.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,19 @@ def api_client(request, database):
149149
search_post_request_model = create_post_request_model(
150150
extensions, base_model=PgstacSearch
151151
)
152+
153+
collections_get_request_model = create_get_request_model(
154+
extensions + collection_extensions
155+
)
156+
152157
api = StacApi(
153158
settings=api_settings,
154159
extensions=extensions + collection_extensions,
155160
client=CoreCrudClient(post_request_model=search_post_request_model),
156161
items_get_request_model=items_get_request_model,
157162
search_get_request_model=search_get_request_model,
158163
search_post_request_model=search_post_request_model,
159-
collections_get_request_model=CollectionSearchExtension().GET,
164+
collections_get_request_model=collections_get_request_model,
160165
response_class=ORJSONResponse,
161166
router=APIRouter(prefix=prefix),
162167
)

0 commit comments

Comments
 (0)