Refactor test cases for improved readability and consistency
All checks were successful
Backend CI / lint (push) Successful in 9m49s
Backend CI / test (push) Successful in 6m15s

- Adjusted function signatures in various test files to enhance clarity by aligning parameters.
- Updated patching syntax for better readability across test cases.
- Improved formatting and spacing in test assertions and mock setups.
- Ensured consistent use of async/await patterns in async test functions.
- Enhanced comments for better understanding of test intentions.
This commit is contained in:
JSC
2025-08-01 20:53:30 +02:00
parent d926779fe4
commit 6068599a47
39 changed files with 691 additions and 286 deletions

View File

@@ -1,6 +1,5 @@
"""Tests for extraction API endpoints."""
import pytest
from httpx import AsyncClient
@@ -10,7 +9,9 @@ class TestExtractionEndpoints:
@pytest.mark.asyncio
async def test_create_extraction_success(
self, test_client: AsyncClient, auth_cookies: dict[str, str],
self,
test_client: AsyncClient,
auth_cookies: dict[str, str],
) -> None:
"""Test successful extraction creation."""
# Set cookies on client instance to avoid deprecation warning
@@ -26,7 +27,9 @@ class TestExtractionEndpoints:
assert response.status_code in [200, 400, 500] # Allow any non-auth error
@pytest.mark.asyncio
async def test_create_extraction_unauthenticated(self, test_client: AsyncClient) -> None:
async def test_create_extraction_unauthenticated(
self, test_client: AsyncClient,
) -> None:
"""Test extraction creation without authentication."""
response = await test_client.post(
"/api/v1/sounds/extract",
@@ -37,7 +40,9 @@ class TestExtractionEndpoints:
assert response.status_code == 401
@pytest.mark.asyncio
async def test_get_extraction_unauthenticated(self, test_client: AsyncClient) -> None:
async def test_get_extraction_unauthenticated(
self, test_client: AsyncClient,
) -> None:
"""Test extraction retrieval without authentication."""
response = await test_client.get("/api/v1/sounds/extract/1")
@@ -46,7 +51,9 @@ class TestExtractionEndpoints:
@pytest.mark.asyncio
async def test_get_processor_status_moved_to_admin(
self, test_client: AsyncClient, admin_cookies: dict[str, str],
self,
test_client: AsyncClient,
admin_cookies: dict[str, str],
) -> None:
"""Test that processor status endpoint was moved to admin."""
# Set cookies on client instance to avoid deprecation warning
@@ -61,7 +68,9 @@ class TestExtractionEndpoints:
@pytest.mark.asyncio
async def test_get_user_extractions(
self, test_client: AsyncClient, auth_cookies: dict[str, str],
self,
test_client: AsyncClient,
auth_cookies: dict[str, str],
) -> None:
"""Test getting user extractions."""
# Set cookies on client instance to avoid deprecation warning