|
1 | 1 | from typing import Iterator
|
2 | 2 |
|
3 | 3 | import pytest
|
| 4 | +from fastapi import APIRouter |
4 | 5 | from starlette.testclient import TestClient
|
5 | 6 |
|
6 | 7 | from stac_fastapi.api.app import StacApi
|
@@ -185,3 +186,28 @@ def test_search_filter_get(client_name, request):
|
185 | 186 | assert response.is_success, response.json()
|
186 | 187 | response_dict = response.json()
|
187 | 188 | assert response_dict["collections"] == ["collection1", "collection2"]
|
| 189 | + |
| 190 | + |
| 191 | +@pytest.mark.parametrize("prefix", ["", "/a_prefix"]) |
| 192 | +def test_multi_ext_prefix(prefix): |
| 193 | + settings = ApiSettings() |
| 194 | + extensions = [ |
| 195 | + SearchFilterExtension(), |
| 196 | + ItemCollectionFilterExtension(), |
| 197 | + # Technically `CollectionSearchFilterExtension` |
| 198 | + # shouldn't be registered to the application but to the collection-search class |
| 199 | + CollectionSearchFilterExtension(), |
| 200 | + ] |
| 201 | + |
| 202 | + api = StacApi( |
| 203 | + settings=settings, |
| 204 | + router=APIRouter(prefix=prefix), |
| 205 | + client=DummyCoreClient(), |
| 206 | + extensions=extensions, |
| 207 | + search_get_request_model=create_get_request_model([SearchFilterExtension()]), |
| 208 | + search_post_request_model=create_post_request_model([SearchFilterExtension()]), |
| 209 | + ) |
| 210 | + with TestClient(api.app, base_url="http://stac.io") as client: |
| 211 | + queryables = client.get(f"{prefix}/queryables") |
| 212 | + assert queryables.status_code == 200, queryables.json() |
| 213 | + assert queryables.headers["content-type"] == "application/schema+json" |
0 commit comments