Skip to content

Commit fcf2760

Browse files
committed
Add tests
1 parent d8d2d9d commit fcf2760

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

stac_fastapi/pgstac/tests/api/test_api.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,40 @@ async def test_search_line_string_intersects(
379379
assert len(resp_json["features"]) == 1
380380

381381

382+
async def test_search_geometry_collection_intersects(
383+
load_test_data, app_client, load_test_collection
384+
):
385+
coll = load_test_collection
386+
item = load_test_data("test_item.json")
387+
resp = await app_client.post(f"/collections/{coll.id}/items", json=item)
388+
assert resp.status_code == 200
389+
390+
point = [150.04, -33.14]
391+
line = [[150.04, -33.14], [150.22, -33.89]]
392+
intersects = {
393+
"type": "GeometryCollection",
394+
"geometries": [
395+
{
396+
"type": "Point",
397+
"coordinates": point
398+
},
399+
{
400+
"type": "LineString",
401+
"coordinates": line
402+
}
403+
]
404+
}
405+
406+
params = {
407+
"intersects": intersects,
408+
"collections": [item["collection"]],
409+
}
410+
resp = await app_client.post("/search", json=params)
411+
assert resp.status_code == 200
412+
resp_json = resp.json()
413+
assert len(resp_json["features"]) == 1
414+
415+
382416
@pytest.mark.asyncio
383417
async def test_landing_forwarded_header(
384418
load_test_data, app_client, load_test_collection

stac_fastapi/sqlalchemy/tests/api/test_api.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,40 @@ def test_search_line_string_intersects(
367367
assert len(resp_json["features"]) == 1
368368

369369

370+
def test_search_geometry_collection_intersects(
371+
load_test_data, app_client, postgres_transactions
372+
):
373+
item = load_test_data("test_item.json")
374+
postgres_transactions.create_item(
375+
item["collection"], item, request=MockStarletteRequest
376+
)
377+
378+
point = [150.04, -33.14]
379+
line = [[150.04, -33.14], [150.22, -33.89]]
380+
intersects = {
381+
"type": "GeometryCollection",
382+
"geometries": [
383+
{
384+
"type": "Point",
385+
"coordinates": point
386+
},
387+
{
388+
"type": "LineString",
389+
"coordinates": line
390+
}
391+
]
392+
}
393+
394+
params = {
395+
"intersects": intersects,
396+
"collections": [item["collection"]],
397+
}
398+
resp = app_client.post("/search", json=params)
399+
assert resp.status_code == 200
400+
resp_json = resp.json()
401+
assert len(resp_json["features"]) == 1
402+
403+
370404
def test_app_fields_extension_return_all_properties(
371405
load_test_data, app_client, postgres_transactions
372406
):

0 commit comments

Comments
 (0)