Skip to content

Commit 53d44ce

Browse files
committed
Adding extra test for start_datetime/end_datetime intersecting searches.
1 parent 0a6616e commit 53d44ce

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

stac_fastapi/elasticsearch/tests/api/test_api.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,13 @@ async def test_app_fields_extension_return_all_properties(app_client, ctx, txn_c
191191
feature = resp_json["features"][0]
192192
assert len(feature["properties"]) >= len(item["properties"])
193193
for expected_prop, expected_value in item["properties"].items():
194-
if expected_prop in ("datetime", "created", "updated"):
194+
if expected_prop in (
195+
"datetime",
196+
"start_datetime",
197+
"end_datetime",
198+
"created",
199+
"updated",
200+
):
195201
assert feature["properties"][expected_prop][0:19] == expected_value[0:19]
196202
else:
197203
assert feature["properties"][expected_prop] == expected_value

stac_fastapi/elasticsearch/tests/data/test_item.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
},
3636
"properties": {
3737
"datetime": "2020-02-12T12:30:22Z",
38+
"start_datetime": "2020-02-08T12:30:22Z",
39+
"end_datetime": "2020-02-16T12:30:22Z",
3840
"landsat:scene_id": "LC82081612020043LGN00",
3941
"landsat:row": "161",
4042
"gsd": 15,

stac_fastapi/elasticsearch/tests/resources/test_item.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,25 @@ async def test_item_search_temporal_window_post(app_client, ctx):
385385
assert resp_json["features"][0]["id"] == test_item["id"]
386386

387387

388+
@pytest.mark.asyncio
389+
async def test_item_search_temporal_intersecting_window_post(app_client, ctx):
390+
"""Test POST search with two-tailed spatio-temporal query (core)"""
391+
test_item = ctx.item
392+
393+
item_date = rfc3339_str_to_datetime(test_item["properties"]["datetime"])
394+
item_date_before = item_date - timedelta(days=10)
395+
item_date_after = item_date - timedelta(days=2)
396+
397+
params = {
398+
"collections": [test_item["collection"]],
399+
"intersects": test_item["geometry"],
400+
"datetime": f"{datetime_to_str(item_date_before)}/{datetime_to_str(item_date_after)}",
401+
}
402+
resp = await app_client.post("/search", json=params)
403+
resp_json = resp.json()
404+
assert resp_json["features"][0]["id"] == test_item["id"]
405+
406+
388407
@pytest.mark.asyncio
389408
@pytest.mark.skip(reason="KeyError: 'features")
390409
async def test_item_search_temporal_open_window(app_client, ctx):

0 commit comments

Comments
 (0)