|
1 | 1 | import importlib
|
2 | 2 |
|
3 | 3 | import pytest
|
4 |
| -from httpx import ASGITransport, AsyncClient |
| 4 | +from starlette.testclient import TestClient |
5 | 5 |
|
6 | 6 | from stac_fastapi.pgstac.db import close_db_connection, connect_to_db
|
7 | 7 |
|
@@ -44,53 +44,53 @@ async def app_with_root_path(database, monkeypatch):
|
44 | 44 |
|
45 | 45 |
|
46 | 46 | @pytest.fixture(scope="function")
|
47 |
| -async def client_with_root_path(app_with_root_path): |
48 |
| - async with AsyncClient( |
49 |
| - transport=ASGITransport(app=app_with_root_path), |
50 |
| - base_url=base_url, |
| 47 | +def client_with_root_path(app_with_root_path): |
| 48 | + with TestClient( |
| 49 | + app_with_root_path, |
| 50 | + root_path=root_path_value, |
51 | 51 | ) as c:
|
52 | 52 | yield c
|
53 | 53 |
|
54 | 54 |
|
55 | 55 | @pytest.fixture(scope="function")
|
56 |
| -async def loaded_client(client_with_root_path, load_test_data): |
| 56 | +def loaded_client(client_with_root_path, load_test_data): |
57 | 57 | col = load_test_data("test_collection.json")
|
58 |
| - resp = await client_with_root_path.post( |
| 58 | + resp = client_with_root_path.post( |
59 | 59 | "/collections",
|
60 | 60 | json=col,
|
61 | 61 | )
|
62 | 62 | assert resp.status_code == 201
|
63 | 63 | item = load_test_data("test_item.json")
|
64 |
| - resp = await client_with_root_path.post( |
| 64 | + resp = client_with_root_path.post( |
65 | 65 | f"/collections/{col['id']}/items",
|
66 | 66 | json=item,
|
67 | 67 | )
|
68 | 68 | assert resp.status_code == 201
|
69 | 69 | item = load_test_data("test_item2.json")
|
70 |
| - resp = await client_with_root_path.post( |
| 70 | + resp = client_with_root_path.post( |
71 | 71 | f"/collections/{col['id']}/items",
|
72 | 72 | json=item,
|
73 | 73 | )
|
74 | 74 | assert resp.status_code == 201
|
75 | 75 | yield client_with_root_path
|
76 | 76 |
|
77 | 77 |
|
78 |
| -async def test_search_links_are_valid(loaded_client): |
79 |
| - resp = await loaded_client.get("/search?limit=1") |
| 78 | +def test_search_links_are_valid(loaded_client): |
| 79 | + resp = loaded_client.get("/search?limit=1") |
80 | 80 | assert resp.status_code == 200
|
81 | 81 | response_json = resp.json()
|
82 | 82 | assert_links_href(response_json.get("links", []), base_url)
|
83 | 83 |
|
84 | 84 |
|
85 |
| -async def test_collection_links_are_valid(loaded_client): |
86 |
| - resp = await loaded_client.get("/collections?limit=1") |
| 85 | +def test_collection_links_are_valid(loaded_client): |
| 86 | + resp = loaded_client.get("/collections?limit=1") |
87 | 87 | assert resp.status_code == 200
|
88 | 88 | response_json = resp.json()
|
89 | 89 | assert_links_href(response_json.get("links", []), base_url)
|
90 | 90 |
|
91 | 91 |
|
92 |
| -async def test_items_collection_links_are_valid(loaded_client): |
93 |
| - resp = await loaded_client.get("/collections/test-collection/items?limit=1") |
| 92 | +def test_items_collection_links_are_valid(loaded_client): |
| 93 | + resp = loaded_client.get("/collections/test-collection/items?limit=1") |
94 | 94 | assert resp.status_code == 200
|
95 | 95 | response_json = resp.json()
|
96 | 96 | assert_links_href(response_json.get("links", []), base_url)
|
|
0 commit comments