Skip to content

Commit 1f6cc05

Browse files
authored
Merge pull request #139 from stac-utils/fix-tests
Fix tests
2 parents 4e12664 + 5525916 commit 1f6cc05

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

stac_fastapi/elasticsearch/tests/resources/test_item.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ async def test_pagination(app_client, load_test_data):
260260
assert second_page["context"]["returned"] == 3
261261

262262

263-
async def test_item_timestamps(app_client, ctx, load_test_data):
263+
async def test_item_timestamps(app_client, ctx):
264264
"""Test created and updated timestamps (common metadata)"""
265265
# start_time = now_to_rfc3339_str()
266266

@@ -335,7 +335,7 @@ async def test_item_search_temporal_query_post(app_client, ctx):
335335
assert resp_json["features"][0]["id"] == test_item["id"]
336336

337337

338-
async def test_item_search_temporal_window_post(app_client, load_test_data, ctx):
338+
async def test_item_search_temporal_window_post(app_client, ctx):
339339
"""Test POST search with two-tailed spatio-temporal query (core)"""
340340
test_item = ctx.item
341341

@@ -649,30 +649,40 @@ async def test_pagination_token_idempotent(app_client, ctx, txn_client):
649649
]
650650

651651

652-
async def test_field_extension_get_includes(app_client):
652+
async def test_field_extension_get_includes(app_client, ctx):
653653
"""Test GET search with included fields (fields extension)"""
654-
params = {"fields": "+properties.proj:epsg,+properties.gsd"}
654+
test_item = ctx.item
655+
params = {
656+
"ids": [test_item["id"]],
657+
"fields": "+properties.proj:epsg,+properties.gsd",
658+
}
655659
resp = await app_client.get("/search", params=params)
656660
feat_properties = resp.json()["features"][0]["properties"]
657661
assert not set(feat_properties) - {"proj:epsg", "gsd", "datetime"}
658662

659663

660-
async def test_field_extension_get_excludes(app_client):
664+
async def test_field_extension_get_excludes(app_client, ctx):
661665
"""Test GET search with included fields (fields extension)"""
662-
params = {"fields": "-properties.proj:epsg,-properties.gsd"}
666+
test_item = ctx.item
667+
params = {
668+
"ids": [test_item["id"]],
669+
"fields": "-properties.proj:epsg,-properties.gsd",
670+
}
663671
resp = await app_client.get("/search", params=params)
664672
resp_json = resp.json()
665673
assert "proj:epsg" not in resp_json["features"][0]["properties"].keys()
666674
assert "gsd" not in resp_json["features"][0]["properties"].keys()
667675

668676

669-
async def test_field_extension_post(app_client):
677+
async def test_field_extension_post(app_client, ctx):
670678
"""Test POST search with included and excluded fields (fields extension)"""
679+
test_item = ctx.item
671680
body = {
681+
"ids": [test_item["id"]],
672682
"fields": {
673683
"exclude": ["assets.B1"],
674684
"include": ["properties.eo:cloud_cover", "properties.orientation"],
675-
}
685+
},
676686
}
677687

678688
resp = await app_client.post("/search", json=body)
@@ -685,23 +695,26 @@ async def test_field_extension_post(app_client):
685695
}
686696

687697

688-
async def test_field_extension_exclude_and_include(app_client, load_test_data):
698+
async def test_field_extension_exclude_and_include(app_client, ctx):
689699
"""Test POST search including/excluding same field (fields extension)"""
700+
test_item = ctx.item
690701
body = {
702+
"ids": [test_item["id"]],
691703
"fields": {
692704
"exclude": ["properties.eo:cloud_cover"],
693705
"include": ["properties.eo:cloud_cover"],
694-
}
706+
},
695707
}
696708

697709
resp = await app_client.post("/search", json=body)
698710
resp_json = resp.json()
699711
assert "eo:cloud_cover" not in resp_json["features"][0]["properties"]
700712

701713

702-
async def test_field_extension_exclude_default_includes(app_client, load_test_data):
714+
async def test_field_extension_exclude_default_includes(app_client, ctx):
703715
"""Test POST search excluding a forbidden field (fields extension)"""
704-
body = {"fields": {"exclude": ["gsd"]}}
716+
test_item = ctx.item
717+
body = {"ids": [test_item["id"]], "fields": {"exclude": ["gsd"]}}
705718

706719
resp = await app_client.post("/search", json=body)
707720
resp_json = resp.json()

0 commit comments

Comments
 (0)