Skip to content

Always generate links for all searches #241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed

- Fixed issue where searches return an empty `links` array [#241](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/241)

## [v2.4.0]

Expand Down
8 changes: 2 additions & 6 deletions stac_fastapi/core/stac_fastapi/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,7 @@ async def item_collection(
if maybe_count is not None:
context_obj["matched"] = maybe_count

links = []
if next_token:
links = await PagingLinks(request=request, next=next_token).get_links()
links = await PagingLinks(request=request, next=next_token).get_links()

return ItemCollection(
type="FeatureCollection",
Expand Down Expand Up @@ -619,9 +617,7 @@ async def post_search(
if maybe_count is not None:
context_obj["matched"] = maybe_count

links = []
if next_token:
links = await PagingLinks(request=request, next=next_token).get_links()
links = await PagingLinks(request=request, next=next_token).get_links()

return ItemCollection(
type="FeatureCollection",
Expand Down
9 changes: 9 additions & 0 deletions stac_fastapi/tests/resources/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,15 @@ async def test_get_missing_item_collection(app_client):
assert resp.status_code == 404


@pytest.mark.asyncio
async def test_pagination_base_links(app_client, ctx):
"""Test that a search query always contains basic links"""
page = await app_client.get(f"/collections/{ctx.item['collection']}/items")

page_data = page.json()
assert {"self", "root"}.issubset({link["rel"] for link in page_data["links"]})


@pytest.mark.asyncio
async def test_pagination_item_collection(app_client, ctx, txn_client):
"""Test item collection pagination links (paging extension)"""
Expand Down