Skip to content

Commit 3f70857

Browse files
committed
fix test to be compatible with both elasticsearch and opensearch
1 parent b3804b5 commit 3f70857

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

stac_fastapi/tests/database/test_database.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
@pytest.mark.asyncio
2626
async def test_index_mapping_collections(ctx):
2727
response = await database.client.indices.get_mapping(index=COLLECTIONS_INDEX)
28-
actual_mappings = next(iter(response.body.values()))["mappings"]
28+
if not isinstance(response, dict):
29+
response = response.body
30+
actual_mappings = next(iter(response.values()))["mappings"]
2931
assert (
3032
actual_mappings["dynamic_templates"]
3133
== ES_COLLECTIONS_MAPPINGS["dynamic_templates"]
@@ -40,7 +42,9 @@ async def test_index_mapping_items(ctx, txn_client):
4042
response = await database.client.indices.get_mapping(
4143
index=index_by_collection_id(collection["id"])
4244
)
43-
actual_mappings = next(iter(response.body.values()))["mappings"]
45+
if not isinstance(response, dict):
46+
response = response.body
47+
actual_mappings = next(iter(response.values()))["mappings"]
4448
assert (
4549
actual_mappings["dynamic_templates"] == ES_ITEMS_MAPPINGS["dynamic_templates"]
4650
)

0 commit comments

Comments
 (0)