stac-utils / stac-fastapi-elasticsearch-opensearch

Elasticsearch backend for stac-fastapi with Opensearch support.
https://stac-utils.github.io/stac-fastapi-elasticsearch-opensearch
MIT License
28 stars 13 forks source link

Sort extension tests failing #262

Closed jamesfisher-geo closed 4 months ago

jamesfisher-geo commented 4 months ago

Some tests of the sort extension are failing when I run make test on a clean pull from main. It looks like this is just due to a type error in the tests introduced in the update to 3.0.0a.

The first_item property needs to be converted to a datetime

another_item_date = first_item["properties"]["datetime"] - timedelta(days=1)

I get

FAILED api/test_api.py::test_app_sort_extension_get_asc - TypeError: unsupported operand type(s) for -: 'str' and 'datetime.timedelta'
FAILED api/test_api.py::test_app_sort_extension_get_desc - TypeError: unsupported operand type(s) for -: 'str' and 'datetime.timedelta'
FAILED api/test_api.py::test_app_sort_extension_post_asc - TypeError: unsupported operand type(s) for -: 'str' and 'datetime.timedelta'
FAILED api/test_api.py::test_app_sort_extension_post_desc - TypeError: unsupported operand type(s) for -: 'str' and 'datetime.timedelta'

To Reproduce

  1. git clone
  2. make test
jonhealy1 commented 4 months ago

Hi. I should have pinned stac-fastapi to 3.0.0a0 instead of 3.0.0a. When stac-fastapi 3.0.0a1 was released it introduced this

jamesfisher-geo commented 4 months ago

Got it. So this is caused by stac-fastapi now requiring datetimes to be timezone aware?

I have the tests passing now in the PR above. Let me know what you think.