feat: Add audio extraction endpoints and refactor sound API routes

This commit is contained in:
JSC
2025-08-01 21:39:42 +02:00
parent 6068599a47
commit d2d0240fdb
9 changed files with 150 additions and 124 deletions

View File

@@ -513,7 +513,7 @@ class TestAdminSoundEndpoints:
mock_get_status.return_value = mock_status
response = await authenticated_admin_client.get(
"/api/v1/admin/sounds/extract/status",
"/api/v1/admin/extractions/status",
)
assert response.status_code == 200
@@ -526,7 +526,7 @@ class TestAdminSoundEndpoints:
client: AsyncClient,
) -> None:
"""Test getting extraction processor status without authentication."""
response = await client.get("/api/v1/admin/sounds/extract/status")
response = await client.get("/api/v1/admin/extractions/status")
assert response.status_code == 401
data = response.json()
@@ -556,7 +556,7 @@ class TestAdminSoundEndpoints:
base_url="http://test",
) as client:
response = await client.get(
"/api/v1/admin/sounds/extract/status",
"/api/v1/admin/extractions/status",
headers=headers,
)

View File

@@ -18,7 +18,7 @@ class TestExtractionEndpoints:
test_client.cookies.update(auth_cookies)
response = await test_client.post(
"/api/v1/sounds/extract",
"/api/v1/extractions/",
params={"url": "https://www.youtube.com/watch?v=test"},
)
@@ -32,7 +32,7 @@ class TestExtractionEndpoints:
) -> None:
"""Test extraction creation without authentication."""
response = await test_client.post(
"/api/v1/sounds/extract",
"/api/v1/extractions/",
params={"url": "https://www.youtube.com/watch?v=test"},
)
@@ -44,7 +44,7 @@ class TestExtractionEndpoints:
self, test_client: AsyncClient,
) -> None:
"""Test extraction retrieval without authentication."""
response = await test_client.get("/api/v1/sounds/extract/1")
response = await test_client.get("/api/v1/extractions/1")
# Should return 401 for missing authentication
assert response.status_code == 401
@@ -60,7 +60,7 @@ class TestExtractionEndpoints:
test_client.cookies.update(admin_cookies)
# The new admin endpoint should work
response = await test_client.get("/api/v1/admin/sounds/extract/status")
response = await test_client.get("/api/v1/admin/extractions/status")
assert response.status_code == 200
data = response.json()
assert "running" in data or "is_running" in data
@@ -76,7 +76,7 @@ class TestExtractionEndpoints:
# Set cookies on client instance to avoid deprecation warning
test_client.cookies.update(auth_cookies)
response = await test_client.get("/api/v1/sounds/extract")
response = await test_client.get("/api/v1/extractions/")
# Should succeed and return empty list (no extractions in test DB)
assert response.status_code == 200

View File

@@ -45,7 +45,7 @@ class TestSoundEndpoints:
mock_queue.return_value = None
response = await authenticated_client.post(
"/api/v1/sounds/extract",
"/api/v1/extractions/",
params={"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"},
)
@@ -62,7 +62,7 @@ class TestSoundEndpoints:
async def test_create_extraction_unauthenticated(self, client: AsyncClient) -> None:
"""Test extraction creation without authentication."""
response = await client.post(
"/api/v1/sounds/extract",
"/api/v1/extractions/",
params={"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"},
)
@@ -83,7 +83,7 @@ class TestSoundEndpoints:
mock_create.side_effect = ValueError("Invalid URL")
response = await authenticated_client.post(
"/api/v1/sounds/extract",
"/api/v1/extractions/",
params={"url": "invalid-url"},
)
@@ -114,7 +114,7 @@ class TestSoundEndpoints:
) as mock_get:
mock_get.return_value = mock_extraction_info
response = await authenticated_client.get("/api/v1/sounds/extract/1")
response = await authenticated_client.get("/api/v1/extractions/1")
assert response.status_code == 200
data = response.json()
@@ -135,7 +135,7 @@ class TestSoundEndpoints:
) as mock_get:
mock_get.return_value = None
response = await authenticated_client.get("/api/v1/sounds/extract/999")
response = await authenticated_client.get("/api/v1/extractions/999")
assert response.status_code == 404
data = response.json()
@@ -176,7 +176,7 @@ class TestSoundEndpoints:
) as mock_get:
mock_get.return_value = mock_extractions
response = await authenticated_client.get("/api/v1/sounds/extract")
response = await authenticated_client.get("/api/v1/extractions/")
assert response.status_code == 200
data = response.json()