From 3f70857ac5e579fdb0f0791feace0d1f5084d6cd Mon Sep 17 00:00:00 2001 From: Stijn Caerts Date: Tue, 12 Mar 2024 16:58:42 +0100 Subject: [PATCH] fix test to be compatible with both elasticsearch and opensearch --- stac_fastapi/tests/database/test_database.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/stac_fastapi/tests/database/test_database.py b/stac_fastapi/tests/database/test_database.py index 74b09ad7..3f7fe5a8 100644 --- a/stac_fastapi/tests/database/test_database.py +++ b/stac_fastapi/tests/database/test_database.py @@ -25,7 +25,9 @@ @pytest.mark.asyncio async def test_index_mapping_collections(ctx): response = await database.client.indices.get_mapping(index=COLLECTIONS_INDEX) - actual_mappings = next(iter(response.body.values()))["mappings"] + if not isinstance(response, dict): + response = response.body + actual_mappings = next(iter(response.values()))["mappings"] assert ( actual_mappings["dynamic_templates"] == ES_COLLECTIONS_MAPPINGS["dynamic_templates"] @@ -40,7 +42,9 @@ async def test_index_mapping_items(ctx, txn_client): response = await database.client.indices.get_mapping( index=index_by_collection_id(collection["id"]) ) - actual_mappings = next(iter(response.body.values()))["mappings"] + if not isinstance(response, dict): + response = response.body + actual_mappings = next(iter(response.values()))["mappings"] assert ( actual_mappings["dynamic_templates"] == ES_ITEMS_MAPPINGS["dynamic_templates"] )