Skip to content

Commit c9e6b0b

Browse files
committed
add fields extension tests
1 parent f7573f6 commit c9e6b0b

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

stac_fastapi/elasticsearch/tests/api/test_api.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,27 @@ async def test_app_context_extension(app_client, ctx, txn_client):
110110
assert matched == 1
111111

112112

113-
@pytest.mark.skip(reason="fields not implemented yet")
114-
async def test_app_fields_extension(load_test_data, app_client, txn_client):
115-
item = load_test_data("test_item.json")
116-
txn_client.create_item(item, request=MockRequest, refresh=True)
117-
113+
async def test_app_fields_extension(app_client, ctx, txn_client):
118114
resp = await app_client.get("/search", params={"collections": ["test-collection"]})
119115
assert resp.status_code == 200
120116
resp_json = resp.json()
121117
assert list(resp_json["features"][0]["properties"]) == ["datetime"]
122118

123-
txn_client.delete_item(item["id"], item["collection"])
119+
120+
async def test_app_fields_extension_return_all_properties(app_client, ctx, txn_client):
121+
item = ctx.item
122+
resp = await app_client.get(
123+
"/search", params={"collections": ["test-collection"], "fields": "properties"}
124+
)
125+
assert resp.status_code == 200
126+
resp_json = resp.json()
127+
feature = resp_json["features"][0]
128+
assert len(feature["properties"]) >= len(item["properties"])
129+
for expected_prop, expected_value in item["properties"].items():
130+
if expected_prop in ("datetime", "created", "updated"):
131+
assert feature["properties"][expected_prop][0:19] == expected_value[0:19]
132+
else:
133+
assert feature["properties"][expected_prop] == expected_value
124134

125135

126136
async def test_app_query_extension_gt(app_client, ctx):

0 commit comments

Comments
 (0)