Add tests for extraction API endpoints and enhance existing tests
- Implement tests for admin extraction API endpoints including status retrieval, deletion of extractions, and permission checks. - Add tests for user extraction deletion, ensuring proper handling of permissions and non-existent extractions. - Enhance sound endpoint tests to include duplicate handling in responses. - Refactor favorite service tests to utilize mock dependencies for better maintainability and clarity. - Update sound scanner tests to improve file handling and ensure proper deletion of associated files.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
"""Tests for favorite API endpoints."""
|
||||
|
||||
from contextlib import suppress
|
||||
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from httpx import AsyncClient
|
||||
@@ -129,10 +131,8 @@ class TestFavoriteEndpoints:
|
||||
) -> None:
|
||||
"""Test successfully adding a sound to favorites."""
|
||||
# Clean up any existing favorite first
|
||||
try:
|
||||
with suppress(Exception):
|
||||
await authenticated_client.delete("/api/v1/favorites/sounds/1")
|
||||
except:
|
||||
pass # It's ok if it doesn't exist
|
||||
|
||||
response = await authenticated_client.post("/api/v1/favorites/sounds/1")
|
||||
|
||||
@@ -176,10 +176,8 @@ class TestFavoriteEndpoints:
|
||||
) -> None:
|
||||
"""Test successfully adding a playlist to favorites."""
|
||||
# Clean up any existing favorite first
|
||||
try:
|
||||
with suppress(Exception):
|
||||
await authenticated_client.delete("/api/v1/favorites/playlists/1")
|
||||
except:
|
||||
pass # It's ok if it doesn't exist
|
||||
|
||||
response = await authenticated_client.post("/api/v1/favorites/playlists/1")
|
||||
|
||||
@@ -473,10 +471,8 @@ class TestFavoriteEndpoints:
|
||||
) -> None:
|
||||
"""Test checking if a sound is favorited (false case)."""
|
||||
# Make sure sound 1 is not favorited
|
||||
try:
|
||||
with suppress(Exception):
|
||||
await authenticated_client.delete("/api/v1/favorites/sounds/1")
|
||||
except:
|
||||
pass # It's ok if it doesn't exist
|
||||
|
||||
response = await authenticated_client.get("/api/v1/favorites/sounds/1/check")
|
||||
|
||||
@@ -509,10 +505,8 @@ class TestFavoriteEndpoints:
|
||||
) -> None:
|
||||
"""Test checking if a playlist is favorited (false case)."""
|
||||
# Make sure playlist 1 is not favorited
|
||||
try:
|
||||
with suppress(Exception):
|
||||
await authenticated_client.delete("/api/v1/favorites/playlists/1")
|
||||
except:
|
||||
pass # It's ok if it doesn't exist
|
||||
|
||||
response = await authenticated_client.get("/api/v1/favorites/playlists/1/check")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user