Skip to content

Commit 9726279

Browse files
committed
test
1 parent 0353cf7 commit 9726279

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

services/api-server/tests/unit/api_solvers/test_api_routers_solvers.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,54 @@ async def test_list_solver_ports_again(
172172
)
173173
assert response.status_code == status.HTTP_200_OK
174174
assert TypeAdapter(OnePage[SolverPort]).validate_python(response.json())
175+
176+
177+
async def test_solvers_page_pagination_links(
178+
mocked_catalog_rpc_api: dict[str, MockType],
179+
client: httpx.AsyncClient,
180+
auth: httpx.BasicAuth,
181+
):
182+
# Use a small limit to ensure pagination is needed
183+
limit = 2
184+
response = await client.get(f"/{API_VTAG}/solvers/page?limit={limit}", auth=auth)
185+
186+
assert response.status_code == status.HTTP_200_OK
187+
188+
response_data = response.json()
189+
assert "links" in response_data, "Response should contain links section"
190+
191+
links = response_data["links"]
192+
assert "next" in links, "Pagination should include 'next' link"
193+
assert "prev" in links, "Pagination should include 'prev' link"
194+
assert "first" in links, "Pagination should include 'first' link"
195+
assert "last" in links, "Pagination should include 'last' link"
196+
assert "self" in links, "Pagination should include 'self' link"
197+
198+
# Verify the self link contains the correct limit parameter
199+
assert (
200+
f"limit={limit}" in links["self"]
201+
), "Self link should reflect the requested limit"
202+
203+
204+
async def test_solvers_page_pagination_last_page(
205+
mocked_catalog_rpc_api: dict[str, MockType],
206+
client: httpx.AsyncClient,
207+
auth: httpx.BasicAuth,
208+
):
209+
# Get total count first
210+
response = await client.get(f"/{API_VTAG}/solvers/page", auth=auth)
211+
assert response.status_code == status.HTTP_200_OK
212+
total_items = response.json()["total"]
213+
214+
# Request the last page by using the total count as offset
215+
response = await client.get(
216+
f"/{API_VTAG}/solvers/page?offset={total_items-1}", auth=auth
217+
)
218+
assert response.status_code == status.HTTP_200_OK
219+
220+
response_data = response.json()
221+
assert "links" in response_data, "Response should contain links section"
222+
223+
links = response_data["links"]
224+
assert links["next"] is None, "Next link should be None for the last page"
225+
assert links["prev"] is not None, "Prev link should be present for the last page"

0 commit comments

Comments
 (0)