Skip to content

Commit edb256f

Browse files
authored
Merge pull request #920 from RS-PYTHON/feat/rspy602-stac-fastapi-pgstac-updates
RSPY-602 - Update stac-fastapi / stac-fastapi-pgstac / pgstac to 5.0.x / 4.0.x / 0.9.x
2 parents 5208f66 + f941113 commit edb256f

File tree

16 files changed

+992
-742
lines changed

16 files changed

+992
-742
lines changed

poetry.lock

Lines changed: 162 additions & 107 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

services/adgs/poetry.lock

Lines changed: 149 additions & 104 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

services/cadip/poetry.lock

Lines changed: 149 additions & 104 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

services/catalog/poetry.lock

Lines changed: 149 additions & 104 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

services/catalog/rs_server_catalog/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ async def dispatch(self, request: Request, call_next: Callable):
301301
return await call_next(request)
302302

303303

304-
client = CoreCrudClient(post_request_model=post_request_model)
304+
client = CoreCrudClient(pgstac_search_model=post_request_model)
305305

306306

307307
class UserCatalogMiddleware(BaseHTTPMiddleware): # pylint: disable=too-few-public-methods
@@ -323,7 +323,7 @@ async def dispatch(self, request, call_next):
323323
settings=settings,
324324
extensions=extensions,
325325
items_get_request_model=items_get_request_model,
326-
client=CoreCrudClient(post_request_model=post_request_model),
326+
client=CoreCrudClient(pgstac_search_model=post_request_model),
327327
response_class=ORJSONResponse,
328328
search_get_request_model=create_get_request_model(extensions),
329329
search_post_request_model=post_request_model,

services/catalog/rs_server_catalog/user_catalog.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -942,10 +942,9 @@ async def manage_get_response( # pylint: disable=too-many-locals, too-many-bran
942942
user_login,
943943
)
944944
content["collections"] = self.update_links_for_all_collections(content["collections"])
945-
self_parser = urlparse(content["links"][2]["href"])
945+
self_parser = urlparse(content["links"][1]["href"])
946946
content["links"][0]["href"] += "catalog/"
947-
content["links"][1]["href"] += "catalog/"
948-
content["links"][2]["href"] = self_parser._replace(path="/catalog/collections").geturl()
947+
content["links"][1]["href"] = self_parser._replace(path="/catalog/collections").geturl()
949948

950949
# If we are in cluster mode and the user_login is not authorized
951950
# to this endpoint returns a HTTP_401_UNAUTHORIZED status.

services/catalog/rs_server_catalog/user_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def reroute_url( # type: ignore # pylint: disable=too-many-branches,too-many-st
111111
path = "/health"
112112

113113
# The endpoint PUT "/catalog/collections" does not exists.
114-
elif path == CATALOG_COLLECTION and method != "PUT":
114+
elif path.rstrip("/") == CATALOG_COLLECTION and method != "PUT":
115115
path = "/collections"
116116

117117
# Catch endpoint /catalog/collections/[{owner_id}:]{collection_id}/bulk_items

services/catalog/tests/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
services:
1616

1717
stac-db:
18-
image: ghcr.io/stac-utils/pgstac:v0.8.6
18+
image: ghcr.io/stac-utils/pgstac:v0.9.2
1919
container_name: postgres-${POSTGRES_DB}
2020
environment:
2121
POSTGRES_USER: ${POSTGRES_USER}

services/catalog/tests/test_authentication_catalog.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ async def test_http200_with_good_authentication(
13041304
)
13051305
assert response.status_code == HTTP_200_OK
13061306
content = json.loads(response.content)
1307-
assert content["context"] == {"limit": 10, "returned": 1}
1307+
assert content["numberReturned"] == 1
13081308

13091309
response = client.request(
13101310
"GET",
@@ -1314,7 +1314,7 @@ async def test_http200_with_good_authentication(
13141314
)
13151315
assert response.status_code == HTTP_200_OK
13161316
content = json.loads(response.content)
1317-
assert content["context"] == {"limit": 10, "returned": 2}
1317+
assert content["numberReturned"] == 2
13181318

13191319
response = client.request(
13201320
"POST",
@@ -1324,7 +1324,7 @@ async def test_http200_with_good_authentication(
13241324
)
13251325
assert response.status_code == HTTP_200_OK
13261326
content = json.loads(response.content)
1327-
assert content["context"] == {"limit": 10, "returned": 2}
1327+
assert content["numberReturned"] == 2
13281328

13291329
@pytest.mark.parametrize("test_apikey, test_oauth2", [[True, False], [False, True]], ids=["apikey", "oauth2"])
13301330
async def test_fails_without_good_perms(self, mocker, httpx_mock: HTTPXMock, client, test_apikey, test_oauth2):

services/catalog/tests/test_endpoints.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ def test_delete_non_empty_collection(self, client, a_minimal_collection, a_corre
698698
"""
699699
first_get_collection_response = client.get("/catalog/collections/fixture_owner:fixture_collection/items")
700700
assert first_get_collection_response.status_code == fastapi.status.HTTP_200_OK
701-
assert json.loads(first_get_collection_response.content)["context"]["returned"] == 0
701+
assert json.loads(first_get_collection_response.content)["numberReturned"] == 0
702702
# Post the feature to the collection
703703
updated_feature_sent = copy.deepcopy(a_correct_feature)
704704
updated_feature_sent["collection"] = "fixture_collection"
@@ -710,7 +710,7 @@ def test_delete_non_empty_collection(self, client, a_minimal_collection, a_corre
710710
# Test that the collection is not empty
711711
second_get_collection_response = client.get("/catalog/collections/fixture_owner:fixture_collection/items")
712712
assert second_get_collection_response.status_code == fastapi.status.HTTP_200_OK
713-
assert json.loads(second_get_collection_response.content)["context"]["returned"] > 0
713+
assert json.loads(second_get_collection_response.content)["numberReturned"] > 0
714714
# Delete the collection
715715
delete_response = client.delete("/catalog/collections/fixture_owner:fixture_collection")
716716
assert delete_response.status_code == fastapi.status.HTTP_200_OK
@@ -1480,7 +1480,7 @@ def test_create_new_minimal_feature(self, client, a_minimal_collection, a_correc
14801480
assert check_features_response.status_code == fastapi.status.HTTP_200_OK
14811481
# Test if query returns only one feature for this collection
14821482
returned_features = json.loads(check_features_response.content)
1483-
assert returned_features["context"]["returned"] == 1
1483+
assert returned_features["numberReturned"] == 1
14841484
# Test feature content
14851485
assert returned_features["features"][0]["id"] == a_correct_feature["id"]
14861486
assert returned_features["features"][0]["geometry"] == a_correct_feature["geometry"]
@@ -1696,7 +1696,7 @@ def test_delete_a_correct_feature(self, client, a_minimal_collection, a_correct_
16961696
collection_content_response = client.get("/catalog/collections/fixture_owner:fixture_collection/items")
16971697
assert collection_content_response.status_code == fastapi.status.HTTP_200_OK
16981698
collection_content_response = json.loads(collection_content_response.content)
1699-
assert collection_content_response["context"]["returned"] == 0
1699+
assert collection_content_response["numberReturned"] == 0
17001700
assert (
17011701
client.delete("/catalog/collections/fixture_owner:fixture_collection").status_code
17021702
== fastapi.status.HTTP_200_OK

0 commit comments

Comments
 (0)