Skip to content

Commit

Permalink
update tests for double open ended temporal interval
Browse files Browse the repository at this point in the history
  • Loading branch information
philvarner committed Mar 31, 2022
1 parent afb4176 commit 7b00142
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
24 changes: 7 additions & 17 deletions stac_fastapi/pgstac/tests/resources/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,27 +457,17 @@ async def test_item_search_temporal_window_post(
async def test_item_search_temporal_open_window(
app_client, load_test_data, load_test_collection
):
"""Test POST search with open spatio-temporal query (core)"""
test_item = load_test_data("test_item.json")
resp = await app_client.post(
f"/collections/{test_item['collection']}/items", json=test_item
)
assert resp.status_code == 200

# Add second item with a different datetime.
second_test_item = load_test_data("test_item2.json")
resp = await app_client.post(
f"/collections/{test_item['collection']}/items", json=second_test_item
)
assert resp.status_code == 200

params = {
"collections": [test_item["collection"]],
"datetime": "../..",
}
resp = await app_client.post("/search", json=params)
resp_json = resp.json()
assert len(resp_json["features"]) == 2
assert resp.status_code == 400

params = {
"datetime": "/",
}
resp = await app_client.post("/search", json=params)
assert resp.status_code == 400


@pytest.mark.asyncio
Expand Down
18 changes: 16 additions & 2 deletions stac_fastapi/types/tests/test_rfc3339.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
from datetime import timezone

import pytest

from stac_fastapi.types.rfc3339 import rfc3339_str_to_datetime, str_to_interval
from stac_fastapi.types.rfc3339 import (
now_in_utc,
now_to_rfc3339_str,
rfc3339_str_to_datetime,
str_to_interval,
)

invalid_datetimes = [
"1985-04-12", # date only
Expand Down Expand Up @@ -88,4 +95,11 @@ def test_parse_valid_interval_to_datetime(test_input):
assert str_to_interval(test_input)


# TODO: add tests for now and str functions
def test_now_functions() -> None:
now1 = now_in_utc()
now2 = now_in_utc()

assert now1 < now2
assert now1.tzinfo == timezone.utc

rfc3339_str_to_datetime(now_to_rfc3339_str())

0 comments on commit 7b00142

Please sign in to comment.