Skip to content

Commit

Permalink
add more tests, just use isodate instead of ciso8601
Browse files Browse the repository at this point in the history
  • Loading branch information
hrodmn committed Nov 4, 2024
1 parent d2d1794 commit 05c56ee
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 37 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ dependencies = [
"titiler.core>=0.18.0,<0.19",
"titiler.mosaic>=0.18.0,<0.19",
"cftime~=1.6.4",
"ciso8601~=2.3",
"earthaccess~=0.11.0",
"fsspec~=2024.9.0",
"h5netcdf~=1.1.0",
Expand Down
16 changes: 16 additions & 0 deletions tests/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,19 @@ def test_timeseries_query_unbounded_intervals(
)

assert len(unbounded_query) == 40


def test_timeseries_mixed_datetime(
xarray_query_params: Dict[str, str],
arctic_bounds: Tuple[float, float, float, float],
) -> None:
"""Test comma-separated mixed points and intervals"""
mixed_query = timeseries_cmr_query(
concept_id=xarray_query_params["concept_id"],
timeseries_params=TimeseriesParams(
datetime="2023-01-01T00:00:00Z,2024-01-01T00:00:00Z/2024-01-05T00:00:00Z",
step="P1D",
temporal_mode="point",
),
)
assert len(mixed_query) == 6
4 changes: 2 additions & 2 deletions titiler/cmr/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from datetime import datetime
from typing import Any, List, Optional, Sequence, Tuple, Type, Union

from ciso8601 import parse_rfc3339
from isodate import parse_datetime as _parse_datetime

from titiler.cmr.errors import InvalidDatetime

Expand Down Expand Up @@ -40,7 +40,7 @@ def _newfn(*args: Any, **kwargs: Any):

def _parse_date(date: str) -> datetime:
try:
return parse_rfc3339(date)
return _parse_datetime(date)
except Exception as e:
raise InvalidDatetime(f"Invalid datetime {date}") from e

Expand Down
35 changes: 1 addition & 34 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 05c56ee

Please sign in to comment.