Skip to content

Commit 7b00142

Browse files
committed
update tests for double open ended temporal interval
1 parent afb4176 commit 7b00142

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

stac_fastapi/pgstac/tests/resources/test_item.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -457,27 +457,17 @@ async def test_item_search_temporal_window_post(
457457
async def test_item_search_temporal_open_window(
458458
app_client, load_test_data, load_test_collection
459459
):
460-
"""Test POST search with open spatio-temporal query (core)"""
461-
test_item = load_test_data("test_item.json")
462-
resp = await app_client.post(
463-
f"/collections/{test_item['collection']}/items", json=test_item
464-
)
465-
assert resp.status_code == 200
466-
467-
# Add second item with a different datetime.
468-
second_test_item = load_test_data("test_item2.json")
469-
resp = await app_client.post(
470-
f"/collections/{test_item['collection']}/items", json=second_test_item
471-
)
472-
assert resp.status_code == 200
473-
474460
params = {
475-
"collections": [test_item["collection"]],
476461
"datetime": "../..",
477462
}
478463
resp = await app_client.post("/search", json=params)
479-
resp_json = resp.json()
480-
assert len(resp_json["features"]) == 2
464+
assert resp.status_code == 400
465+
466+
params = {
467+
"datetime": "/",
468+
}
469+
resp = await app_client.post("/search", json=params)
470+
assert resp.status_code == 400
481471

482472

483473
@pytest.mark.asyncio

stac_fastapi/types/tests/test_rfc3339.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
from datetime import timezone
2+
13
import pytest
24

3-
from stac_fastapi.types.rfc3339 import rfc3339_str_to_datetime, str_to_interval
5+
from stac_fastapi.types.rfc3339 import (
6+
now_in_utc,
7+
now_to_rfc3339_str,
8+
rfc3339_str_to_datetime,
9+
str_to_interval,
10+
)
411

512
invalid_datetimes = [
613
"1985-04-12", # date only
@@ -88,4 +95,11 @@ def test_parse_valid_interval_to_datetime(test_input):
8895
assert str_to_interval(test_input)
8996

9097

91-
# TODO: add tests for now and str functions
98+
def test_now_functions() -> None:
99+
now1 = now_in_utc()
100+
now2 = now_in_utc()
101+
102+
assert now1 < now2
103+
assert now1.tzinfo == timezone.utc
104+
105+
rfc3339_str_to_datetime(now_to_rfc3339_str())

0 commit comments

Comments
 (0)