Skip to content

Commit 9626f09

Browse files
committed
Removed hardcoded value, added UT
1 parent 760b7e4 commit 9626f09

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

services/cadip/rs_server_cadip/api/cadip_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ def process_session_search( # type: ignore # pylint: disable=too-many-arguments
474474
sortby: str,
475475
limit: Annotated[
476476
Union[int, None],
477-
Query(gt=0, le=10000, default=1000, description="Pagination Limit"),
477+
Query(gt=0, default=1000, description="Pagination Limit"),
478478
],
479479
page: Union[int, None] = 1,
480480
) -> stac_pydantic.ItemCollection:

tests/test_search_endpoint.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,36 @@ def test_invalid_limit_values(self, client, endpoint):
903903
"Input should be greater than 0",
904904
)
905905

906+
@pytest.mark.unit
907+
@pytest.mark.parametrize(
908+
"endpoint, odata",
909+
[
910+
(
911+
"/auxip/collections/s2_adgs2_AUX_OBMEMC/items?limit=10000000",
912+
"http://127.0.0.1:5001/Products?$filter=Attributes/OData.CSC.StringAttribute/any(att:att/Name eq "
913+
"'productType' and att/OData.CSC.StringAttribute/Value eq 'AUX_OBMEMC')&$orderby=PublicationDate "
914+
"desc&$top=9999&$skip=0&$expand=Attributes",
915+
),
916+
(
917+
"/cadip/collections/cadip_session_by_id/items?limit=10000000",
918+
"http://127.0.0.1:5000/Sessions?$filter=SessionId eq 'S1A_20200105072204051312'&$orderby="
919+
"PublicationDate desc&$top=9999&$skip=0",
920+
),
921+
],
922+
)
923+
@responses.activate
924+
def test_bigger_limit_than_allowed(self, client, mock_token_validation, endpoint, odata):
925+
"""
926+
Test that if user request with a limit value bigger than max allowed in config
927+
the limit value is set to max_allowed - 1.
928+
Limit in request is set to 1_000_000, for given collection max allowed is set to 10000, therefore
929+
in the final odata request, $top is set to 9999.
930+
"""
931+
mock_token_validation()
932+
responses.add(responses.GET, odata, json={"value": []}, status=200)
933+
response = client.get(endpoint)
934+
assert response.status_code == status.HTTP_200_OK
935+
906936
@pytest.mark.unit
907937
@pytest.mark.parametrize(
908938
"endpoint",

0 commit comments

Comments
 (0)