From f5a372df531578151480be189334d9eff30c67bf Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Tue, 21 May 2024 11:41:55 +0200 Subject: [PATCH 1/2] set start/end datetime to the unique datetime passed in api.Search --- CHANGELOG.txt | 1 + stac_pydantic/api/search.py | 4 ++-- tests/api/test_search.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index ffb7e10..4f5f121 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -13,6 +13,7 @@ - use `StacBaseModel` as base model for `Asset` model (#148, @vincentsarago) - add `license` in `StacCommonMetadata` model (#147, @vincentsarago) - make `limit` optional in `api.Search` model (#150, @vincentsarago) +- set `start/end datetime` to the datetime value when passing only one value in `api.Search` 3.0.0 (2024-01-25) ------------------ diff --git a/stac_pydantic/api/search.py b/stac_pydantic/api/search.py index c68fd60..57cfac0 100644 --- a/stac_pydantic/api/search.py +++ b/stac_pydantic/api/search.py @@ -108,9 +108,9 @@ def validate_datetime(cls, value: str) -> str: "Invalid datetime range. Too many values. Must match format: {begin_date}/{end_date}" ) - # If there is only one date, insert a None for the start date + # If there is only one date, duplicate to use for both start and end dates if len(values) == 1: - values.insert(0, None) + values = [values[0], values[0]] # Cast because pylance gets confused by the type adapter and annotated type dates = cast( diff --git a/tests/api/test_search.py b/tests/api/test_search.py index 15fd19c..8fc24af 100644 --- a/tests/api/test_search.py +++ b/tests/api/test_search.py @@ -58,7 +58,7 @@ def test_temporal_search_single_tailed(): utcnow = datetime.now(timezone.utc) utcnow_str = utcnow.isoformat() search = Search(collections=["collection1"], datetime=utcnow_str) - assert search.start_date is None + assert search.start_date == utcnow assert search.end_date == utcnow From c1c94789a871fbac5972f28efaef857e002986c8 Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Tue, 21 May 2024 16:37:00 +0200 Subject: [PATCH 2/2] update changelog --- CHANGELOG.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 4f5f121..209f055 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -13,7 +13,7 @@ - use `StacBaseModel` as base model for `Asset` model (#148, @vincentsarago) - add `license` in `StacCommonMetadata` model (#147, @vincentsarago) - make `limit` optional in `api.Search` model (#150, @vincentsarago) -- set `start/end datetime` to the datetime value when passing only one value in `api.Search` +- set `start/end datetime` to the datetime value when passing only one value in `api.Search` (#152, @vincentsarago) 3.0.0 (2024-01-25) ------------------