Skip to content

Commit

Permalink
fix: removed deprecated server context extension (#891)
Browse files Browse the repository at this point in the history
  • Loading branch information
dalpasso authored Dec 6, 2023
1 parent 6823a97 commit b6dd367
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 40 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ An eodag instance can be exposed through a STAC compliant REST api from the comm
# search for items
$ curl "http://127.0.0.1:5000/search?collections=S2_MSI_L1C&bbox=0,43,1,44&datetime=2018-01-20/2018-01-25" \
| jq ".context.matched"
| jq ".numberMatched"
6
# browse for items
$ curl "http://127.0.0.1:5000/catalogs/S2_MSI_L1C/country/FRA/year/2021/month/01/day/25/cloud_cover/10/items" \
| jq ".context.matched"
| jq ".numberMatched"
9
# get download link
Expand Down
4 changes: 2 additions & 2 deletions docs/stac_rest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ Example
# search for items
$ curl "http://127.0.0.1:5000/search?collections=S2_MSI_L1C&bbox=0,43,1,44&datetime=2018-01-20/2018-01-25" \
| jq ".context.matched"
| jq ".numberMatched"
6
# browse for items
$ curl "http://127.0.0.1:5000/catalogs/S2_MSI_L1C/country/FRA/year/2021/month/01/day/25/cloud_cover/10/items" \
| jq ".context.matched"
| jq ".numberMatched"
9
# get download link
Expand Down
6 changes: 0 additions & 6 deletions eodag/api/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1891,13 +1891,7 @@ def load_stac_items(
max_connections=max_connections,
timeout=timeout,
)
nb_features = len(features)
feature_collection = geojson.FeatureCollection(features)
feature_collection["context"] = {
"limit": nb_features,
"matched": nb_features,
"returned": nb_features,
}

plugin = next(
self._plugins_manager.get_search_plugins(
Expand Down
5 changes: 0 additions & 5 deletions eodag/plugins/search/static_stac_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,6 @@ def query(
)
nb_features = len(features)
feature_collection = geojson.FeatureCollection(features)
feature_collection["context"] = {
"limit": nb_features,
"matched": nb_features,
"returned": nb_features,
}

# save StaticStacSearch._request and mock it to make return loaded static results
stacapi_request = self._request
Expand Down
6 changes: 0 additions & 6 deletions eodag/resources/stac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,6 @@ items:
numberMatched: '$.search_results.numberMatched'
# len(features)
numberReturned: '$.search_results.numberReturned'
# 0.7.0 stac-browser compatibility
context:
page: '$.search_results.properties.page'
limit: '$.search_results.properties.itemsPerPage'
matched: '$.search_results.properties.totalResults'
returned: '$.search_results.numberReturned'

# https://stacspec.org/STAC-api.html#operation/getFeature
item:
Expand Down
2 changes: 1 addition & 1 deletion eodag/resources/stac_provider.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ search:
results_entry: features
pagination:
next_page_query_obj: '{{"limit":{items_per_page},"page":{page}}}'
total_items_nb_key_path: '$.context.matched'
total_items_nb_key_path: '$.numberMatched'
next_page_url_key_path: '$.links[?(@.rel="next")].href'
next_page_query_obj_key_path: '$.links[?(@.rel="next")].body'
next_page_merge_key_path: '$.links[?(@.rel="next")].merge'
Expand Down
3 changes: 0 additions & 3 deletions tests/integration/test_core_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ def test_core_providers_config_update(
mock__request.return_value = mock.Mock()
mock__request_side_effect = [
{
"context": {
"matched": 1,
},
"features": [
{
"id": "foo",
Expand Down
6 changes: 0 additions & 6 deletions tests/resources/provider_responses/earth_search_search.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
"type": "FeatureCollection",
"stac_version": "1.0.0-beta.2",
"stac_extensions": [],
"context": {
"page": 1,
"limit": 1,
"matched": 21830128,
"returned": 1
},
"numberMatched": 21830128,
"numberReturned": 1,
"features": [
Expand Down
5 changes: 0 additions & 5 deletions tests/units/test_http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,11 +829,6 @@ def test_search_response_contains_pagination_info(self):
response = self._request_valid(f"search?collections={self.tested_product_type}")
self.assertIn("numberMatched", response)
self.assertIn("numberReturned", response)
self.assertIn("context", response)
self.assertEqual(1, response["context"]["page"])
self.assertEqual(DEFAULT_ITEMS_PER_PAGE, response["context"]["limit"])
self.assertIn("matched", response["context"])
self.assertIn("returned", response["context"])

def test_search_provider_in_downloadlink(self):
"""Search through eodag server and check that specified provider appears in downloadLink"""
Expand Down
4 changes: 0 additions & 4 deletions tests/units/test_search_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,6 @@ def test_plugins_search_odatav4search_distinct_product_type_mtd_mapping(
geojson_geometry = self.search_criteria_s2_msi_l1c["geometry"].__geo_interface__
mock__request.return_value = mock.Mock()
result = {
"context": {"matched": 1},
"features": [
{
"id": "foo",
Expand Down Expand Up @@ -1117,7 +1116,6 @@ def test_plugins_search_stacsearch_mapping_earthsearch(self, mock__request):
mock__request.return_value = mock.Mock()
mock__request.return_value.json.side_effect = [
{
"context": {"page": 1, "limit": 2, "matched": 1, "returned": 2},
"features": [
{
"id": "foo",
Expand Down Expand Up @@ -1171,7 +1169,6 @@ def test_plugins_search_stacsearch_default_geometry(self, mock__request):
mock__request.return_value = mock.Mock()
mock__request.return_value.json.side_effect = [
{
"context": {"matched": 3},
"features": [
{
"id": "foo",
Expand Down Expand Up @@ -1204,7 +1201,6 @@ def test_plugins_search_stacsearch_distinct_product_type_mtd_mapping(
"""The metadata mapping for a stac provider should not mix specific product-types metadata-mapping"""
mock__request.return_value = mock.Mock()
result = {
"context": {"matched": 1},
"features": [
{
"id": "foo",
Expand Down

0 comments on commit b6dd367

Please sign in to comment.