Skip to content

Aggregation self link with collection specified #295

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 2 commits into from
Sep 4, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added

### Changed
- Fixed the `self` link for the `/collections/{collection_id}/aggregations` endpoint. [#295](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/295)

## [v3.1.0] - 2024-09-02

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ async def get_aggregations(self, collection_id: Optional[str] = None, **kwargs):
{
"rel": "self",
"type": "application/json",
"href": urljoin(collection_endpoint, "aggregations"),
"href": urljoin(collection_endpoint + "/", "aggregations"),
},
]
)
Expand Down
11 changes: 11 additions & 0 deletions stac_fastapi/tests/extensions/test_aggregation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from urllib.parse import urlparse

import pytest

Expand Down Expand Up @@ -68,6 +69,11 @@ async def test_get_collection_aggregations(app_client, ctx, load_test_data):
resp = await app_client.get(f"/collections/{test_collection['id']}/aggregations")
assert resp.status_code == 200
assert len(resp.json()["aggregations"]) == 15
rj = resp.json()
href_self = urlparse(
next(link["href"] for link in rj["links"] if link["rel"] == "self")
)
assert href_self.path == f"/collections/{test_collection['id']}/aggregations"

resp = await app_client.delete(f"/collections/{test_collection['id']}")
assert resp.status_code == 204
Expand All @@ -86,6 +92,11 @@ async def test_post_collection_aggregations(app_client, ctx, load_test_data):
resp = await app_client.post(f"/collections/{test_collection['id']}/aggregations")
assert resp.status_code == 200
assert len(resp.json()["aggregations"]) == 15
rj = resp.json()
href_self = urlparse(
next(link["href"] for link in rj["links"] if link["rel"] == "self")
)
assert href_self.path == f"/collections/{test_collection['id']}/aggregations"

resp = await app_client.delete(f"/collections/{test_collection['id']}")
assert resp.status_code == 204
Expand Down