Skip to content

Commit 92ed789

Browse files
committed
Get rid of txn_client in test_queryables_enum_platform
1 parent ab2eb10 commit 92ed789

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

stac_fastapi/tests/extensions/test_filter.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
import json
22
import logging
33
import os
4+
import uuid
45
from os import listdir
56
from os.path import isfile, join
67
from typing import Callable, Dict
78

89
import pytest
910
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
1511

1612
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
1713

@@ -636,16 +632,19 @@ async def test_search_filter_extension_cql2text_s_disjoint_property(app_client,
636632
@pytest.mark.asyncio
637633
async def test_queryables_enum_platform(
638634
app_client: AsyncClient,
639-
txn_client: TransactionsClient,
640635
load_test_data: Callable[[str], Dict],
636+
monkeypatch: pytest.MonkeyPatch,
641637
):
642638
# Arrange
639+
# Enforce instant database refresh
640+
# TODO: Is there a better way to do this?
641+
monkeypatch.setenv("DATABASE_REFRESH", "true")
642+
643643
# Create collection
644644
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()
649648

650649
# Create items with different platform values
651650
NUM_ITEMS = 3
@@ -654,12 +653,8 @@ async def test_queryables_enum_platform(
654653
item_data["id"] = f"enum-test-item-{i}"
655654
item_data["collection"] = collection_id
656655
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()
663658

664659
# Act
665660
# Test queryables endpoint
@@ -677,4 +672,5 @@ async def test_queryables_enum_platform(
677672
assert set(platform_values) == {"landsat-8", "sentinel-2"}
678673

679674
# 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

Comments
 (0)