Skip to content

Commit 2727609

Browse files
committed
add test_collection_defaults
Tests that all 'core' stac properties are populated w/ default values if omitted by client during collection creation
1 parent 53ef8e0 commit 2727609

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

stac_fastapi/elasticsearch/tests/resources/test_collection.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@
55

66
from ..conftest import create_collection, delete_collections_and_items, refresh_indices
77

8+
CORE_COLLECTION_PROPS = [
9+
"id",
10+
"type",
11+
"stac_extensions",
12+
"stac_version",
13+
"title",
14+
"description",
15+
"keywords",
16+
"license",
17+
"providers",
18+
"summaries",
19+
"extent",
20+
"links",
21+
"assets",
22+
]
23+
824

925
@pytest.mark.asyncio
1026
async def test_create_and_delete_collection(app_client, load_test_data):
@@ -98,6 +114,18 @@ async def test_collection_extensions(ctx, app_client):
98114
assert resp.json().get("item_assets", {}).get("test") == test_asset
99115

100116

117+
@pytest.mark.asyncio
118+
async def test_collection_defaults(app_client):
119+
"""Test that properties omitted by client are populated w/ default values"""
120+
minimal_coll = {"id": str(uuid.uuid4())}
121+
resp = await app_client.post("/collections", json=minimal_coll)
122+
123+
assert resp.status_code == 200
124+
resp_json = resp.json()
125+
for prop in CORE_COLLECTION_PROPS:
126+
assert prop in resp_json.keys()
127+
128+
101129
@pytest.mark.asyncio
102130
async def test_pagination_collection(app_client, ctx, txn_client):
103131
"""Test collection pagination links"""

0 commit comments

Comments
 (0)