1
1
import json
2
2
import logging
3
3
import os
4
+ import uuid
4
5
from os import listdir
5
6
from os .path import isfile , join
6
7
from typing import Callable , Dict
7
8
8
9
import pytest
9
10
from httpx import AsyncClient
10
- from stac_pydantic import api
11
-
12
- from stac_fastapi .core .core import TransactionsClient
13
-
14
- from ..conftest import MockRequest
15
11
16
12
THIS_DIR = os .path .dirname (os .path .abspath (__file__ ))
17
13
@@ -636,16 +632,19 @@ async def test_search_filter_extension_cql2text_s_disjoint_property(app_client,
636
632
@pytest .mark .asyncio
637
633
async def test_queryables_enum_platform (
638
634
app_client : AsyncClient ,
639
- txn_client : TransactionsClient ,
640
635
load_test_data : Callable [[str ], Dict ],
636
+ monkeypatch : pytest .MonkeyPatch ,
641
637
):
642
638
# Arrange
639
+ # Enforce instant database refresh
640
+ # TODO: Is there a better way to do this?
641
+ monkeypatch .setenv ("DATABASE_REFRESH" , "true" )
642
+
643
643
# Create collection
644
644
collection_data = load_test_data ("test_collection.json" )
645
- collection_id = collection_data ["id" ] = "enum-test-collection"
646
- await txn_client .create_collection (
647
- api .Collection (** collection_data ), request = MockRequest
648
- )
645
+ collection_id = collection_data ["id" ] = f"enum-test-collection-{ uuid .uuid4 ()} "
646
+ r = await app_client .post ("/collections" , json = collection_data )
647
+ r .raise_for_status ()
649
648
650
649
# Create items with different platform values
651
650
NUM_ITEMS = 3
@@ -654,12 +653,8 @@ async def test_queryables_enum_platform(
654
653
item_data ["id" ] = f"enum-test-item-{ i } "
655
654
item_data ["collection" ] = collection_id
656
655
item_data ["properties" ]["platform" ] = "landsat-8" if i % 2 else "sentinel-2"
657
- await txn_client .create_item (
658
- collection_id = collection_id ,
659
- item = api .Item (** item_data ),
660
- request = MockRequest ,
661
- refresh = i == NUM_ITEMS ,
662
- )
656
+ r = await app_client .post (f"/collections/{ collection_id } /items" , json = item_data )
657
+ r .raise_for_status ()
663
658
664
659
# Act
665
660
# Test queryables endpoint
@@ -677,4 +672,5 @@ async def test_queryables_enum_platform(
677
672
assert set (platform_values ) == {"landsat-8" , "sentinel-2" }
678
673
679
674
# Clean up
680
- await txn_client .delete_collection (collection_id )
675
+ r = await app_client .delete (f"/collections/{ collection_id } " )
676
+ r .raise_for_status ()
0 commit comments