Skip to content

Commit

Permalink
Merge pull request #241 from pedro-cf/pagination-links-issue
Browse files Browse the repository at this point in the history
Always generate links for all searches
  • Loading branch information
jonhealy1 authored May 6, 2024
2 parents f797ed4 + bff0152 commit 8660a13
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
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

0 comments on commit 8660a13

Please sign in to comment.