Skip to content

Commit

Permalink
Repair API sort tests (#264)
Browse files Browse the repository at this point in the history
**Related Issue(s):**

- #262 

**Description:**

Edit to four tests of the sort extension. The timezone `Z` character was
not being included with the `.replace` command. So it was removed and
`Z` is appended to the datetime string.

**PR Checklist:**

- [x] Code is formatted and linted (run `pre-commit run --all-files`)
- [x] Tests pass (run `make test`)
- [x] Documentation has been updated to reflect changes, if applicable
- [x] Changes are added to the changelog
  • Loading branch information
jamesfisher-geo authored May 29, 2024
1 parent 49fecf9 commit 1b350a2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed

- API sort extension tests [#264](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/264)

## [v3.0.0a1]

### Changed
Expand Down
18 changes: 13 additions & 5 deletions stac_fastapi/tests/api/test_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import uuid
from datetime import timedelta
from datetime import datetime, timedelta, timezone

import pytest

Expand Down Expand Up @@ -245,7 +245,9 @@ async def test_app_sort_extension_get_asc(app_client, txn_client, ctx):

second_item = dict(first_item)
second_item["id"] = "another-item"
another_item_date = first_item["properties"]["datetime"] - timedelta(days=1)
another_item_date = datetime.strptime(
first_item["properties"]["datetime"], "%Y-%m-%dT%H:%M:%SZ"
).replace(tzinfo=timezone.utc) - timedelta(days=1)
second_item["properties"]["datetime"] = another_item_date.isoformat().replace(
"+00:00", "Z"
)
Expand All @@ -265,7 +267,9 @@ async def test_app_sort_extension_get_desc(app_client, txn_client, ctx):

second_item = dict(first_item)
second_item["id"] = "another-item"
another_item_date = first_item["properties"]["datetime"] - timedelta(days=1)
another_item_date = datetime.strptime(
first_item["properties"]["datetime"], "%Y-%m-%dT%H:%M:%SZ"
).replace(tzinfo=timezone.utc) - timedelta(days=1)
second_item["properties"]["datetime"] = another_item_date.isoformat().replace(
"+00:00", "Z"
)
Expand All @@ -284,7 +288,9 @@ async def test_app_sort_extension_post_asc(app_client, txn_client, ctx):

second_item = dict(first_item)
second_item["id"] = "another-item"
another_item_date = first_item["properties"]["datetime"] - timedelta(days=1)
another_item_date = datetime.strptime(
first_item["properties"]["datetime"], "%Y-%m-%dT%H:%M:%SZ"
).replace(tzinfo=timezone.utc) - timedelta(days=1)
second_item["properties"]["datetime"] = another_item_date.isoformat().replace(
"+00:00", "Z"
)
Expand All @@ -307,7 +313,9 @@ async def test_app_sort_extension_post_desc(app_client, txn_client, ctx):

second_item = dict(first_item)
second_item["id"] = "another-item"
another_item_date = first_item["properties"]["datetime"] - timedelta(days=1)
another_item_date = datetime.strptime(
first_item["properties"]["datetime"], "%Y-%m-%dT%H:%M:%SZ"
).replace(tzinfo=timezone.utc) - timedelta(days=1)
second_item["properties"]["datetime"] = another_item_date.isoformat().replace(
"+00:00", "Z"
)
Expand Down

0 comments on commit 1b350a2

Please sign in to comment.