Skip to content

Commit

Permalink
ruff autorformat test
Browse files Browse the repository at this point in the history
  • Loading branch information
kdcokenny committed Jun 28, 2024
1 parent f3d1e8e commit 9bbe6cc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 25 deletions.
36 changes: 21 additions & 15 deletions tests/sqlalchemy/endpoint/test_endpoint_custom_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@
from fastcrud import crud_router


@pytest.mark.parametrize('custom_endpoint_names, endpoint_paths', [
(
@pytest.mark.parametrize(
"custom_endpoint_names, endpoint_paths",
[
(
{"create": "", "read": "", "read_multi": ""},
["/test_custom_names", "/test_custom_names",
"/test_custom_names"]
),
(
["/test_custom_names", "/test_custom_names", "/test_custom_names"],
),
(
{"create": "add", "read": "fetch", "read_multi": "fetch_multi"},
["/test_custom_names/add", "/test_custom_names/fetch",
"/test_custom_names/fetch_multi"]),
])
[
"/test_custom_names/add",
"/test_custom_names/fetch",
"/test_custom_names/fetch_multi",
],
),
],
)
@pytest.mark.asyncio
async def test_endpoint_custom_names(
client: TestClient,
Expand Down Expand Up @@ -54,19 +60,19 @@ async def test_endpoint_custom_names(

item_id = create_response.json()["id"]

fetch_response = client.get(f'{read_path}/{item_id}')
fetch_response = client.get(f"{read_path}/{item_id}")
assert (
fetch_response.status_code == 200
), "Failed to fetch item with custom endpoint name"
assert (
fetch_response.json()["id"] == item_id
), (f"Fetched item ID does not match created item ID:"
f" {fetch_response.json()['id']} != {item_id}")
assert fetch_response.json()["id"] == item_id, (
f"Fetched item ID does not match created item ID:"
f" {fetch_response.json()['id']} != {item_id}"
)

fetch_multi_response = client.get(read_multi_path)
assert (
fetch_multi_response.status_code == 200
), "Failed to fetch multi items with custom endpoint name"
assert (
len(fetch_multi_response.json()['data']) == 12
len(fetch_multi_response.json()["data"]) == 12
), "Fetched item list has incorrect length"
12 changes: 7 additions & 5 deletions tests/sqlalchemy/endpoint/test_get_paginated.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ async def test_read_paginated_with_filters(

# ------ the following tests will completely replace the current ones in the next version of fastcrud ------
@pytest.mark.asyncio
async def test_read_items_with_pagination(client: TestClient, async_session, test_model, test_data):
async def test_read_items_with_pagination(
client: TestClient, async_session, test_model, test_data
):
for data in test_data:
new_item = test_model(**data)
async_session.add(new_item)
Expand All @@ -100,9 +102,7 @@ async def test_read_items_with_pagination(client: TestClient, async_session, tes
page = 1
items_per_page = 5

response = client.get(
f"/test/get_multi?page={page}&itemsPerPage={items_per_page}"
)
response = client.get(f"/test/get_multi?page={page}&itemsPerPage={items_per_page}")

assert response.status_code == 200

Expand All @@ -125,7 +125,9 @@ async def test_read_items_with_pagination(client: TestClient, async_session, tes


@pytest.mark.asyncio
async def test_read_items_with_pagination_and_filters(filtered_client: TestClient, async_session, test_model, test_data):
async def test_read_items_with_pagination_and_filters(
filtered_client: TestClient, async_session, test_model, test_data
):
for data in test_data:
new_item = test_model(**data)
async_session.add(new_item)
Expand Down
12 changes: 7 additions & 5 deletions tests/sqlmodel/endpoint/test_get_paginated.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ async def test_read_paginated_with_filters(

# ------ the following tests will completely replace the current ones in the next version of fastcrud ------
@pytest.mark.asyncio
async def test_read_items_with_pagination(client: TestClient, async_session, test_model, test_data):
async def test_read_items_with_pagination(
client: TestClient, async_session, test_model, test_data
):
for data in test_data:
new_item = test_model(**data)
async_session.add(new_item)
Expand All @@ -100,9 +102,7 @@ async def test_read_items_with_pagination(client: TestClient, async_session, tes
page = 1
items_per_page = 5

response = client.get(
f"/test/get_multi?page={page}&itemsPerPage={items_per_page}"
)
response = client.get(f"/test/get_multi?page={page}&itemsPerPage={items_per_page}")

assert response.status_code == 200

Expand All @@ -125,7 +125,9 @@ async def test_read_items_with_pagination(client: TestClient, async_session, tes


@pytest.mark.asyncio
async def test_read_items_with_pagination_and_filters(filtered_client: TestClient, async_session, test_model, test_data):
async def test_read_items_with_pagination_and_filters(
filtered_client: TestClient, async_session, test_model, test_data
):
for data in test_data:
new_item = test_model(**data)
async_session.add(new_item)
Expand Down

0 comments on commit 9bbe6cc

Please sign in to comment.