Skip to content

Commit 2573cf1

Browse files
committed
update changelog, tests, mark tests
1 parent 7f1b5e5 commit 2573cf1

File tree

7 files changed

+83
-54
lines changed

7 files changed

+83
-54
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2121
- Corrected the closing of client connections in ES index management functions [#132](https://github.com/stac-utils/stac-fastapi-elasticsearch/issues/132)
2222
- Corrected the automatic converstion of float values to int when building Filter Clauses [#135](https://github.com/stac-utils/stac-fastapi-elasticsearch/issues/135)
2323
- Remove unsupported characters from Elasticsearch index names [#153](https://github.com/stac-utils/stac-fastapi-elasticsearch/issues/153)
24+
- Fixed GET /search sortby requests https://github.com/stac-utils/stac-fastapi-elasticsearch/issues/25
2425

2526
## [v0.3.0]
2627

stac_fastapi/elasticsearch/tests/clients/test_elasticsearch.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from ..conftest import MockRequest, create_item
1212

1313

14+
@pytest.mark.asyncio
1415
async def test_create_collection(app_client, ctx, core_client, txn_client):
1516
in_coll = deepcopy(ctx.collection)
1617
in_coll["id"] = str(uuid.uuid4())
@@ -20,6 +21,7 @@ async def test_create_collection(app_client, ctx, core_client, txn_client):
2021
await txn_client.delete_collection(in_coll["id"])
2122

2223

24+
@pytest.mark.asyncio
2325
async def test_create_collection_already_exists(app_client, ctx, txn_client):
2426
data = deepcopy(ctx.collection)
2527

@@ -32,6 +34,7 @@ async def test_create_collection_already_exists(app_client, ctx, txn_client):
3234
await txn_client.delete_collection(data["id"])
3335

3436

37+
@pytest.mark.asyncio
3538
async def test_update_collection(
3639
core_client,
3740
txn_client,
@@ -49,6 +52,7 @@ async def test_update_collection(
4952
await txn_client.delete_collection(data["id"])
5053

5154

55+
@pytest.mark.asyncio
5256
async def test_delete_collection(
5357
core_client,
5458
txn_client,
@@ -63,6 +67,7 @@ async def test_delete_collection(
6367
await core_client.get_collection(data["id"], request=MockRequest)
6468

6569

70+
@pytest.mark.asyncio
6671
async def test_get_collection(
6772
core_client,
6873
txn_client,
@@ -76,6 +81,7 @@ async def test_get_collection(
7681
await txn_client.delete_collection(data["id"])
7782

7883

84+
@pytest.mark.asyncio
7985
async def test_get_item(app_client, ctx, core_client):
8086
got_item = await core_client.get_item(
8187
item_id=ctx.item["id"],
@@ -86,6 +92,7 @@ async def test_get_item(app_client, ctx, core_client):
8692
assert got_item["collection"] == ctx.item["collection"]
8793

8894

95+
@pytest.mark.asyncio
8996
async def test_get_collection_items(app_client, ctx, core_client, txn_client):
9097
coll = ctx.collection
9198
num_of_items_to_create = 5
@@ -106,6 +113,7 @@ async def test_get_collection_items(app_client, ctx, core_client, txn_client):
106113
assert item["collection"] == coll["id"]
107114

108115

116+
@pytest.mark.asyncio
109117
async def test_create_item(ctx, core_client, txn_client):
110118
resp = await core_client.get_item(
111119
ctx.item["id"], ctx.item["collection"], request=MockRequest
@@ -115,6 +123,7 @@ async def test_create_item(ctx, core_client, txn_client):
115123
) == Item(**resp).dict(exclude={"links": ..., "properties": {"created", "updated"}})
116124

117125

126+
@pytest.mark.asyncio
118127
async def test_create_item_already_exists(ctx, txn_client):
119128
with pytest.raises(ConflictError):
120129
await txn_client.create_item(
@@ -125,6 +134,7 @@ async def test_create_item_already_exists(ctx, txn_client):
125134
)
126135

127136

137+
@pytest.mark.asyncio
128138
async def test_update_item(ctx, core_client, txn_client):
129139
ctx.item["properties"]["foo"] = "bar"
130140
collection_id = ctx.item["collection"]
@@ -139,6 +149,7 @@ async def test_update_item(ctx, core_client, txn_client):
139149
assert updated_item["properties"]["foo"] == "bar"
140150

141151

152+
@pytest.mark.asyncio
142153
async def test_update_geometry(ctx, core_client, txn_client):
143154
new_coordinates = [
144155
[
@@ -163,6 +174,7 @@ async def test_update_geometry(ctx, core_client, txn_client):
163174
assert updated_item["geometry"]["coordinates"] == new_coordinates
164175

165176

177+
@pytest.mark.asyncio
166178
async def test_delete_item(ctx, core_client, txn_client):
167179
await txn_client.delete_item(ctx.item["id"], ctx.item["collection"])
168180

@@ -172,6 +184,7 @@ async def test_delete_item(ctx, core_client, txn_client):
172184
)
173185

174186

187+
@pytest.mark.asyncio
175188
async def test_bulk_item_insert(ctx, core_client, txn_client, bulk_txn_client):
176189
items = {}
177190
for _ in range(10):
@@ -193,6 +206,7 @@ async def test_bulk_item_insert(ctx, core_client, txn_client, bulk_txn_client):
193206
# )
194207

195208

209+
@pytest.mark.asyncio
196210
async def test_feature_collection_insert(
197211
core_client,
198212
txn_client,
@@ -212,6 +226,7 @@ async def test_feature_collection_insert(
212226
assert len(fc["features"]) >= 10
213227

214228

229+
@pytest.mark.asyncio
215230
async def test_landing_page_no_collection_title(ctx, core_client, txn_client, app):
216231
ctx.collection["id"] = "new_id"
217232
del ctx.collection["title"]

stac_fastapi/elasticsearch/tests/extensions/test_filter.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
from os import listdir
44
from os.path import isfile, join
55

6+
import pytest
7+
68
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
79

810

11+
@pytest.mark.asyncio
912
async def test_search_filters(app_client, ctx):
1013

1114
filters = []
@@ -19,6 +22,7 @@ async def test_search_filters(app_client, ctx):
1922
assert resp.status_code == 200
2023

2124

25+
@pytest.mark.asyncio
2226
async def test_search_filter_extension_eq(app_client, ctx):
2327
params = {"filter": {"op": "=", "args": [{"property": "id"}, ctx.item["id"]]}}
2428
resp = await app_client.post("/search", json=params)
@@ -27,6 +31,7 @@ async def test_search_filter_extension_eq(app_client, ctx):
2731
assert len(resp_json["features"]) == 1
2832

2933

34+
@pytest.mark.asyncio
3035
async def test_search_filter_extension_gte(app_client, ctx):
3136
# there's one item that can match, so one of these queries should match it and the other shouldn't
3237
params = {
@@ -58,6 +63,7 @@ async def test_search_filter_extension_gte(app_client, ctx):
5863
assert len(resp.json()["features"]) == 0
5964

6065

66+
@pytest.mark.asyncio
6167
async def test_search_filter_ext_and(app_client, ctx):
6268
params = {
6369
"filter": {
@@ -80,6 +86,7 @@ async def test_search_filter_ext_and(app_client, ctx):
8086
assert len(resp.json()["features"]) == 1
8187

8288

89+
@pytest.mark.asyncio
8390
async def test_search_filter_extension_floats(app_client, ctx):
8491
sun_elevation = ctx.item["properties"]["view:sun_elevation"]
8592

stac_fastapi/elasticsearch/tests/resources/test_collection.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import pystac
2+
import pytest
23

34

5+
@pytest.mark.asyncio
46
async def test_create_and_delete_collection(app_client, load_test_data):
57
"""Test creation and deletion of a collection"""
68
test_collection = load_test_data("test_collection.json")
@@ -13,19 +15,22 @@ async def test_create_and_delete_collection(app_client, load_test_data):
1315
assert resp.status_code == 204
1416

1517

18+
@pytest.mark.asyncio
1619
async def test_create_collection_conflict(app_client, ctx):
1720
"""Test creation of a collection which already exists"""
1821
# This collection ID is created in the fixture, so this should be a conflict
1922
resp = await app_client.post("/collections", json=ctx.collection)
2023
assert resp.status_code == 409
2124

2225

26+
@pytest.mark.asyncio
2327
async def test_delete_missing_collection(app_client):
2428
"""Test deletion of a collection which does not exist"""
2529
resp = await app_client.delete("/collections/missing-collection")
2630
assert resp.status_code == 404
2731

2832

33+
@pytest.mark.asyncio
2934
async def test_update_collection_already_exists(ctx, app_client):
3035
"""Test updating a collection which already exists"""
3136
ctx.collection["keywords"].append("test")
@@ -38,6 +43,7 @@ async def test_update_collection_already_exists(ctx, app_client):
3843
assert "test" in resp_json["keywords"]
3944

4045

46+
@pytest.mark.asyncio
4147
async def test_update_new_collection(app_client, load_test_data):
4248
"""Test updating a collection which does not exist (same as creation)"""
4349
test_collection = load_test_data("test_collection.json")
@@ -47,12 +53,14 @@ async def test_update_new_collection(app_client, load_test_data):
4753
assert resp.status_code == 404
4854

4955

56+
@pytest.mark.asyncio
5057
async def test_collection_not_found(app_client):
5158
"""Test read a collection which does not exist"""
5259
resp = await app_client.get("/collections/does-not-exist")
5360
assert resp.status_code == 404
5461

5562

63+
@pytest.mark.asyncio
5664
async def test_returns_valid_collection(ctx, app_client):
5765
"""Test validates fetched collection with jsonschema"""
5866
resp = await app_client.put("/collections", json=ctx.collection)

stac_fastapi/elasticsearch/tests/resources/test_conformance.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def get_link(landing_page, rel_type):
2020
)
2121

2222

23+
@pytest.mark.asyncio
2324
async def test_landing_page_health(response):
2425
"""Test landing page"""
2526
assert response.status_code == 200
@@ -39,6 +40,7 @@ async def test_landing_page_health(response):
3940
]
4041

4142

43+
@pytest.mark.asyncio
4244
@pytest.mark.parametrize("rel_type,expected_media_type,expected_path", link_tests)
4345
async def test_landing_page_links(
4446
response_json, app_client, rel_type, expected_media_type, expected_path
@@ -59,6 +61,7 @@ async def test_landing_page_links(
5961
# code here seems meaningless since it would be the same as if the endpoint did not exist. Once
6062
# https://github.com/stac-utils/stac-fastapi/pull/227 has been merged we can add this to the
6163
# parameterized tests above.
64+
@pytest.mark.asyncio
6265
async def test_search_link(response_json):
6366
search_link = get_link(response_json, "search")
6467

0 commit comments

Comments
 (0)