Skip to content

Commit c7376a6

Browse files
committed
refactor: use starlette.testclient.TestClient
1 parent 938b598 commit c7376a6

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

tests/api/test_links_with_root_path.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import importlib
22

33
import pytest
4-
from httpx import ASGITransport, AsyncClient
4+
from starlette.testclient import TestClient
55

66
from stac_fastapi.pgstac.db import close_db_connection, connect_to_db
77

@@ -44,53 +44,53 @@ async def app_with_root_path(database, monkeypatch):
4444

4545

4646
@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,
5151
) as c:
5252
yield c
5353

5454

5555
@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):
5757
col = load_test_data("test_collection.json")
58-
resp = await client_with_root_path.post(
58+
resp = client_with_root_path.post(
5959
"/collections",
6060
json=col,
6161
)
6262
assert resp.status_code == 201
6363
item = load_test_data("test_item.json")
64-
resp = await client_with_root_path.post(
64+
resp = client_with_root_path.post(
6565
f"/collections/{col['id']}/items",
6666
json=item,
6767
)
6868
assert resp.status_code == 201
6969
item = load_test_data("test_item2.json")
70-
resp = await client_with_root_path.post(
70+
resp = client_with_root_path.post(
7171
f"/collections/{col['id']}/items",
7272
json=item,
7373
)
7474
assert resp.status_code == 201
7575
yield client_with_root_path
7676

7777

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")
8080
assert resp.status_code == 200
8181
response_json = resp.json()
8282
assert_links_href(response_json.get("links", []), base_url)
8383

8484

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")
8787
assert resp.status_code == 200
8888
response_json = resp.json()
8989
assert_links_href(response_json.get("links", []), base_url)
9090

9191

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")
9494
assert resp.status_code == 200
9595
response_json = resp.json()
9696
assert_links_href(response_json.get("links", []), base_url)

0 commit comments

Comments
 (0)