-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Index templates
- Loading branch information
Showing
9 changed files
with
171 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import os | ||
import uuid | ||
from copy import deepcopy | ||
|
||
import pytest | ||
|
||
from ..conftest import MockRequest, database | ||
|
||
if os.getenv("BACKEND", "elasticsearch").lower() == "opensearch": | ||
from stac_fastapi.opensearch.database_logic import ( | ||
COLLECTIONS_INDEX, | ||
ES_COLLECTIONS_MAPPINGS, | ||
ES_ITEMS_MAPPINGS, | ||
index_by_collection_id, | ||
) | ||
else: | ||
from stac_fastapi.elasticsearch.database_logic import ( | ||
COLLECTIONS_INDEX, | ||
ES_COLLECTIONS_MAPPINGS, | ||
ES_ITEMS_MAPPINGS, | ||
index_by_collection_id, | ||
) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_index_mapping_collections(ctx): | ||
response = await database.client.indices.get_mapping(index=COLLECTIONS_INDEX) | ||
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"] | ||
) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_index_mapping_items(ctx, txn_client): | ||
collection = deepcopy(ctx.collection) | ||
collection["id"] = str(uuid.uuid4()) | ||
await txn_client.create_collection(collection, request=MockRequest) | ||
response = await database.client.indices.get_mapping( | ||
index=index_by_collection_id(collection["id"]) | ||
) | ||
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"] | ||
) | ||
await txn_client.delete_collection(collection["id"]) |