Skip to content

Commit 9583f5a

Browse files
committed
test desc ids
1 parent 038db36 commit 9583f5a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

stac_fastapi/tests/api/test_api_search_collections.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,25 @@ async def test_collections_sort_id_asc(app_client, txn_client, ctx):
4444
for i, expected_id in enumerate(sorted_ids):
4545
assert test_collections[i]["id"] == expected_id
4646

47+
# Test descending sort by id
48+
resp = await app_client.get(
49+
"/collections",
50+
params=[("sortby", "-id")],
51+
)
52+
assert resp.status_code == 200
53+
resp_json = resp.json()
54+
55+
# Filter collections to only include the ones we created for this test
56+
test_collections = [
57+
c for c in resp_json["collections"] if c["id"].startswith(test_prefix)
58+
]
59+
60+
# Collections should be sorted in reverse alphabetical order by id
61+
sorted_ids = sorted(collection_ids, reverse=True)
62+
assert len(test_collections) == len(collection_ids)
63+
for i, expected_id in enumerate(sorted_ids):
64+
assert test_collections[i]["id"] == expected_id
65+
4766

4867
@pytest.mark.asyncio
4968
async def test_collections_sort_id_desc(app_client, txn_client, ctx):

0 commit comments

Comments
 (0)