Skip to content

Commit

Permalink
fix test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
igorbenav committed Dec 23, 2024
1 parent f2d55c7 commit e00695f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/sqlalchemy/endpoint/test_get_paginated.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,25 @@ async def test_read_items_with_pagination_and_filters(

for item in data["data"]:
assert item["name"] == name


@pytest.mark.asyncio
async def test_read_items_with_partial_pagination_params(
client: TestClient, async_session, test_model, test_data
):
for data in test_data:
new_item = test_model(**data)
async_session.add(new_item)
await async_session.commit()

response = client.get("/test/get_multi?page=2")
assert response.status_code == 200
data = response.json()
assert data["page"] == 2
assert data["items_per_page"] == 10

response = client.get("/test/get_multi?itemsPerPage=5")
assert response.status_code == 200
data = response.json()
assert data["page"] == 1
assert data["items_per_page"] == 5
22 changes: 22 additions & 0 deletions tests/sqlmodel/endpoint/test_get_paginated.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,25 @@ async def test_read_items_with_only_page_on_pagination(

assert data["page"] == page
assert data["items_per_page"] == 10


@pytest.mark.asyncio
async def test_read_items_with_partial_pagination_params(
client: TestClient, async_session, test_model, test_data
):
for data in test_data:
new_item = test_model(**data)
async_session.add(new_item)
await async_session.commit()

response = client.get("/test/get_multi?page=2")
assert response.status_code == 200
data = response.json()
assert data["page"] == 2
assert data["items_per_page"] == 10

response = client.get("/test/get_multi?itemsPerPage=5")
assert response.status_code == 200
data = response.json()
assert data["page"] == 1
assert data["items_per_page"] == 5

0 comments on commit e00695f

Please sign in to comment.