fix: Lint fixes of last tests
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"""Tests for API token endpoints."""
|
||||
# ruff: noqa: ARG002, PLR2004, PLC0415, BLE001, E501
|
||||
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from unittest.mock import patch
|
||||
@@ -17,7 +18,7 @@ class TestApiTokenEndpoints:
|
||||
self,
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test successful API token generation."""
|
||||
request_data = {"expires_days": 30}
|
||||
|
||||
@@ -45,7 +46,7 @@ class TestApiTokenEndpoints:
|
||||
async def test_generate_api_token_default_expiry(
|
||||
self,
|
||||
authenticated_client: AsyncClient,
|
||||
):
|
||||
) -> None:
|
||||
"""Test API token generation with default expiry."""
|
||||
response = await authenticated_client.post("/api/v1/auth/api-token", json={})
|
||||
|
||||
@@ -54,9 +55,7 @@ class TestApiTokenEndpoints:
|
||||
|
||||
expires_at_str = data["expires_at"]
|
||||
# Handle both ISO format with/without timezone info
|
||||
if expires_at_str.endswith("Z"):
|
||||
expires_at = datetime.fromisoformat(expires_at_str.replace("Z", "+00:00"))
|
||||
elif "+" in expires_at_str or expires_at_str.count("-") > 2:
|
||||
if expires_at_str.endswith("Z") or "+" in expires_at_str or expires_at_str.count("-") > 2:
|
||||
expires_at = datetime.fromisoformat(expires_at_str)
|
||||
else:
|
||||
# Naive datetime, assume UTC
|
||||
@@ -71,7 +70,7 @@ class TestApiTokenEndpoints:
|
||||
async def test_generate_api_token_custom_expiry(
|
||||
self,
|
||||
authenticated_client: AsyncClient,
|
||||
):
|
||||
) -> None:
|
||||
"""Test API token generation with custom expiry."""
|
||||
expires_days = 90
|
||||
request_data = {"expires_days": expires_days}
|
||||
@@ -86,9 +85,7 @@ class TestApiTokenEndpoints:
|
||||
|
||||
expires_at_str = data["expires_at"]
|
||||
# Handle both ISO format with/without timezone info
|
||||
if expires_at_str.endswith("Z"):
|
||||
expires_at = datetime.fromisoformat(expires_at_str.replace("Z", "+00:00"))
|
||||
elif "+" in expires_at_str or expires_at_str.count("-") > 2:
|
||||
if expires_at_str.endswith("Z") or "+" in expires_at_str or expires_at_str.count("-") > 2:
|
||||
expires_at = datetime.fromisoformat(expires_at_str)
|
||||
else:
|
||||
# Naive datetime, assume UTC
|
||||
@@ -103,7 +100,7 @@ class TestApiTokenEndpoints:
|
||||
async def test_generate_api_token_validation_errors(
|
||||
self,
|
||||
authenticated_client: AsyncClient,
|
||||
):
|
||||
) -> None:
|
||||
"""Test API token generation with validation errors."""
|
||||
# Test minimum validation
|
||||
response = await authenticated_client.post(
|
||||
@@ -120,7 +117,7 @@ class TestApiTokenEndpoints:
|
||||
assert response.status_code == 422
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_generate_api_token_unauthenticated(self, client: AsyncClient):
|
||||
async def test_generate_api_token_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test API token generation without authentication."""
|
||||
response = await client.post(
|
||||
"/api/v1/auth/api-token",
|
||||
@@ -132,7 +129,7 @@ class TestApiTokenEndpoints:
|
||||
async def test_get_api_token_status_no_token(
|
||||
self,
|
||||
authenticated_client: AsyncClient,
|
||||
):
|
||||
) -> None:
|
||||
"""Test getting API token status when user has no token."""
|
||||
response = await authenticated_client.get("/api/v1/auth/api-token/status")
|
||||
|
||||
@@ -147,7 +144,7 @@ class TestApiTokenEndpoints:
|
||||
async def test_get_api_token_status_with_token(
|
||||
self,
|
||||
authenticated_client: AsyncClient,
|
||||
):
|
||||
) -> None:
|
||||
"""Test getting API token status when user has a token."""
|
||||
# First generate a token
|
||||
await authenticated_client.post(
|
||||
@@ -170,7 +167,7 @@ class TestApiTokenEndpoints:
|
||||
self,
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test getting API token status with expired token."""
|
||||
# Mock expired token
|
||||
with patch("app.utils.auth.TokenUtils.is_token_expired", return_value=True):
|
||||
@@ -190,7 +187,7 @@ class TestApiTokenEndpoints:
|
||||
assert data["is_expired"] is True
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_api_token_status_unauthenticated(self, client: AsyncClient):
|
||||
async def test_get_api_token_status_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test getting API token status without authentication."""
|
||||
response = await client.get("/api/v1/auth/api-token/status")
|
||||
assert response.status_code == 401
|
||||
@@ -199,7 +196,7 @@ class TestApiTokenEndpoints:
|
||||
async def test_revoke_api_token_success(
|
||||
self,
|
||||
authenticated_client: AsyncClient,
|
||||
):
|
||||
) -> None:
|
||||
"""Test successful API token revocation."""
|
||||
# First generate a token
|
||||
await authenticated_client.post(
|
||||
@@ -230,7 +227,7 @@ class TestApiTokenEndpoints:
|
||||
async def test_revoke_api_token_no_token(
|
||||
self,
|
||||
authenticated_client: AsyncClient,
|
||||
):
|
||||
) -> None:
|
||||
"""Test revoking API token when user has no token."""
|
||||
response = await authenticated_client.delete("/api/v1/auth/api-token")
|
||||
|
||||
@@ -239,7 +236,7 @@ class TestApiTokenEndpoints:
|
||||
assert data["message"] == "API token revoked successfully"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_revoke_api_token_unauthenticated(self, client: AsyncClient):
|
||||
async def test_revoke_api_token_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test revoking API token without authentication."""
|
||||
response = await client.delete("/api/v1/auth/api-token")
|
||||
assert response.status_code == 401
|
||||
@@ -249,7 +246,7 @@ class TestApiTokenEndpoints:
|
||||
self,
|
||||
client: AsyncClient,
|
||||
authenticated_client: AsyncClient,
|
||||
):
|
||||
) -> None:
|
||||
"""Test successful authentication using API token."""
|
||||
# Generate API token
|
||||
token_response = await authenticated_client.post(
|
||||
@@ -268,7 +265,7 @@ class TestApiTokenEndpoints:
|
||||
assert "email" in data
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_api_token_authentication_invalid_token(self, client: AsyncClient):
|
||||
async def test_api_token_authentication_invalid_token(self, client: AsyncClient) -> None:
|
||||
"""Test authentication with invalid API token."""
|
||||
headers = {"API-TOKEN": "invalid_token"}
|
||||
response = await client.get("/api/v1/auth/me", headers=headers)
|
||||
@@ -282,7 +279,7 @@ class TestApiTokenEndpoints:
|
||||
self,
|
||||
client: AsyncClient,
|
||||
authenticated_client: AsyncClient,
|
||||
):
|
||||
) -> None:
|
||||
"""Test authentication with expired API token."""
|
||||
# Generate API token
|
||||
token_response = await authenticated_client.post(
|
||||
@@ -301,7 +298,7 @@ class TestApiTokenEndpoints:
|
||||
assert "API token has expired" in data["detail"]
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_api_token_authentication_empty_token(self, client: AsyncClient):
|
||||
async def test_api_token_authentication_empty_token(self, client: AsyncClient) -> None:
|
||||
"""Test authentication with empty API-TOKEN header."""
|
||||
# Empty token
|
||||
headers = {"API-TOKEN": ""}
|
||||
@@ -325,7 +322,7 @@ class TestApiTokenEndpoints:
|
||||
client: AsyncClient,
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test authentication with API token for inactive user."""
|
||||
# Generate API token
|
||||
token_response = await authenticated_client.post(
|
||||
@@ -351,7 +348,7 @@ class TestApiTokenEndpoints:
|
||||
client: AsyncClient,
|
||||
authenticated_client: AsyncClient,
|
||||
auth_cookies: dict[str, str],
|
||||
):
|
||||
) -> None:
|
||||
"""Test that flexible authentication prefers API token over cookie."""
|
||||
# Generate API token
|
||||
token_response = await authenticated_client.post(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Tests for authentication endpoints."""
|
||||
# ruff: noqa: ARG002, PLR2004, E501, PLC0415, ANN401
|
||||
|
||||
from typing import Any
|
||||
from unittest.mock import patch
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Tests for extraction API endpoints."""
|
||||
# ruff: noqa: PLR2004, E501
|
||||
|
||||
|
||||
import pytest
|
||||
@@ -11,7 +12,7 @@ class TestExtractionEndpoints:
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_extraction_success(
|
||||
self, test_client: AsyncClient, auth_cookies: dict[str, str],
|
||||
):
|
||||
) -> None:
|
||||
"""Test successful extraction creation."""
|
||||
# Set cookies on client instance to avoid deprecation warning
|
||||
test_client.cookies.update(auth_cookies)
|
||||
@@ -26,7 +27,7 @@ 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):
|
||||
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 +38,7 @@ class TestExtractionEndpoints:
|
||||
assert response.status_code == 401
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_extraction_unauthenticated(self, test_client: AsyncClient):
|
||||
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")
|
||||
|
||||
@@ -47,7 +48,7 @@ class TestExtractionEndpoints:
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_processor_status_admin(
|
||||
self, test_client: AsyncClient, admin_cookies: dict[str, str],
|
||||
):
|
||||
) -> None:
|
||||
"""Test getting processor status as admin."""
|
||||
# Set cookies on client instance to avoid deprecation warning
|
||||
test_client.cookies.update(admin_cookies)
|
||||
@@ -63,7 +64,7 @@ class TestExtractionEndpoints:
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_processor_status_non_admin(
|
||||
self, test_client: AsyncClient, auth_cookies: dict[str, str],
|
||||
):
|
||||
) -> None:
|
||||
"""Test getting processor status as non-admin user."""
|
||||
# Set cookies on client instance to avoid deprecation warning
|
||||
test_client.cookies.update(auth_cookies)
|
||||
@@ -77,7 +78,7 @@ class TestExtractionEndpoints:
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_user_extractions(
|
||||
self, test_client: AsyncClient, auth_cookies: dict[str, str],
|
||||
):
|
||||
) -> None:
|
||||
"""Test getting user extractions."""
|
||||
# Set cookies on client instance to avoid deprecation warning
|
||||
test_client.cookies.update(auth_cookies)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Tests for player API endpoints."""
|
||||
# ruff: noqa: ARG002, PLR2004, ANN001, ANN201
|
||||
|
||||
from unittest.mock import AsyncMock, Mock, patch
|
||||
|
||||
@@ -37,7 +38,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test starting playback successfully."""
|
||||
response = await authenticated_client.post("/api/v1/player/play")
|
||||
|
||||
@@ -48,7 +49,7 @@ class TestPlayerEndpoints:
|
||||
mock_player_service.play.assert_called_once_with()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_play_unauthenticated(self, client: AsyncClient):
|
||||
async def test_play_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test starting playback without authentication."""
|
||||
response = await client.post("/api/v1/player/play")
|
||||
assert response.status_code == 401
|
||||
@@ -59,7 +60,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test starting playback with service error."""
|
||||
mock_player_service.play.side_effect = Exception("Service error")
|
||||
|
||||
@@ -75,7 +76,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test playing sound at specific index successfully."""
|
||||
index = 2
|
||||
response = await authenticated_client.post(f"/api/v1/player/play/{index}")
|
||||
@@ -92,7 +93,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test playing sound with invalid index."""
|
||||
mock_player_service.play.side_effect = ValueError("Invalid sound index")
|
||||
|
||||
@@ -108,7 +109,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test playing sound at index with service error."""
|
||||
mock_player_service.play.side_effect = Exception("Service error")
|
||||
|
||||
@@ -124,7 +125,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test pausing playback successfully."""
|
||||
response = await authenticated_client.post("/api/v1/player/pause")
|
||||
|
||||
@@ -135,7 +136,7 @@ class TestPlayerEndpoints:
|
||||
mock_player_service.pause.assert_called_once()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_pause_unauthenticated(self, client: AsyncClient):
|
||||
async def test_pause_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test pausing playback without authentication."""
|
||||
response = await client.post("/api/v1/player/pause")
|
||||
assert response.status_code == 401
|
||||
@@ -146,7 +147,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test pausing playback with service error."""
|
||||
mock_player_service.pause.side_effect = Exception("Service error")
|
||||
|
||||
@@ -162,7 +163,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test stopping playback successfully."""
|
||||
response = await authenticated_client.post("/api/v1/player/stop")
|
||||
|
||||
@@ -173,7 +174,7 @@ class TestPlayerEndpoints:
|
||||
mock_player_service.stop_playback.assert_called_once()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_stop_unauthenticated(self, client: AsyncClient):
|
||||
async def test_stop_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test stopping playback without authentication."""
|
||||
response = await client.post("/api/v1/player/stop")
|
||||
assert response.status_code == 401
|
||||
@@ -184,7 +185,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test stopping playback with service error."""
|
||||
mock_player_service.stop_playback.side_effect = Exception("Service error")
|
||||
|
||||
@@ -200,7 +201,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test skipping to next track successfully."""
|
||||
response = await authenticated_client.post("/api/v1/player/next")
|
||||
|
||||
@@ -211,7 +212,7 @@ class TestPlayerEndpoints:
|
||||
mock_player_service.next.assert_called_once()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_next_track_unauthenticated(self, client: AsyncClient):
|
||||
async def test_next_track_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test skipping to next track without authentication."""
|
||||
response = await client.post("/api/v1/player/next")
|
||||
assert response.status_code == 401
|
||||
@@ -222,7 +223,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test skipping to next track with service error."""
|
||||
mock_player_service.next.side_effect = Exception("Service error")
|
||||
|
||||
@@ -238,7 +239,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test going to previous track successfully."""
|
||||
response = await authenticated_client.post("/api/v1/player/previous")
|
||||
|
||||
@@ -249,7 +250,7 @@ class TestPlayerEndpoints:
|
||||
mock_player_service.previous.assert_called_once()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_previous_track_unauthenticated(self, client: AsyncClient):
|
||||
async def test_previous_track_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test going to previous track without authentication."""
|
||||
response = await client.post("/api/v1/player/previous")
|
||||
assert response.status_code == 401
|
||||
@@ -260,7 +261,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test going to previous track with service error."""
|
||||
mock_player_service.previous.side_effect = Exception("Service error")
|
||||
|
||||
@@ -276,7 +277,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test seeking to position successfully."""
|
||||
position = 5000
|
||||
response = await authenticated_client.post(
|
||||
@@ -296,7 +297,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test seeking with invalid position."""
|
||||
response = await authenticated_client.post(
|
||||
"/api/v1/player/seek",
|
||||
@@ -306,7 +307,7 @@ class TestPlayerEndpoints:
|
||||
assert response.status_code == 422 # Validation error
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_seek_unauthenticated(self, client: AsyncClient):
|
||||
async def test_seek_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test seeking without authentication."""
|
||||
response = await client.post(
|
||||
"/api/v1/player/seek",
|
||||
@@ -320,7 +321,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test seeking with service error."""
|
||||
mock_player_service.seek.side_effect = Exception("Service error")
|
||||
|
||||
@@ -339,7 +340,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test setting volume successfully."""
|
||||
volume = 75
|
||||
response = await authenticated_client.post(
|
||||
@@ -359,7 +360,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test setting volume with invalid range."""
|
||||
# Test volume too high
|
||||
response = await authenticated_client.post(
|
||||
@@ -376,7 +377,7 @@ class TestPlayerEndpoints:
|
||||
assert response.status_code == 422
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_set_volume_unauthenticated(self, client: AsyncClient):
|
||||
async def test_set_volume_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test setting volume without authentication."""
|
||||
response = await client.post(
|
||||
"/api/v1/player/volume",
|
||||
@@ -390,7 +391,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test setting volume with service error."""
|
||||
mock_player_service.set_volume.side_effect = Exception("Service error")
|
||||
|
||||
@@ -409,7 +410,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test setting playback mode successfully."""
|
||||
mode = PlayerMode.LOOP
|
||||
response = await authenticated_client.post(
|
||||
@@ -429,7 +430,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test setting invalid playback mode."""
|
||||
response = await authenticated_client.post(
|
||||
"/api/v1/player/mode",
|
||||
@@ -439,7 +440,7 @@ class TestPlayerEndpoints:
|
||||
assert response.status_code == 422 # Validation error
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_set_mode_unauthenticated(self, client: AsyncClient):
|
||||
async def test_set_mode_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test setting mode without authentication."""
|
||||
response = await client.post(
|
||||
"/api/v1/player/mode",
|
||||
@@ -453,7 +454,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test setting mode with service error."""
|
||||
mock_player_service.set_mode.side_effect = Exception("Service error")
|
||||
|
||||
@@ -472,7 +473,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test reloading playlist successfully."""
|
||||
response = await authenticated_client.post("/api/v1/player/reload-playlist")
|
||||
|
||||
@@ -483,7 +484,7 @@ class TestPlayerEndpoints:
|
||||
mock_player_service.reload_playlist.assert_called_once()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_reload_playlist_unauthenticated(self, client: AsyncClient):
|
||||
async def test_reload_playlist_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test reloading playlist without authentication."""
|
||||
response = await client.post("/api/v1/player/reload-playlist")
|
||||
assert response.status_code == 401
|
||||
@@ -494,7 +495,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test reloading playlist with service error."""
|
||||
mock_player_service.reload_playlist.side_effect = Exception("Service error")
|
||||
|
||||
@@ -510,7 +511,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test getting player state successfully."""
|
||||
mock_state = {
|
||||
"status": PlayerStatus.PLAYING.value,
|
||||
@@ -548,7 +549,7 @@ class TestPlayerEndpoints:
|
||||
mock_player_service.get_state.assert_called_once()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_state_unauthenticated(self, client: AsyncClient):
|
||||
async def test_get_state_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test getting player state without authentication."""
|
||||
response = await client.get("/api/v1/player/state")
|
||||
assert response.status_code == 401
|
||||
@@ -559,7 +560,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test getting player state with service error."""
|
||||
mock_player_service.get_state.side_effect = Exception("Service error")
|
||||
|
||||
@@ -574,7 +575,7 @@ class TestPlayerEndpoints:
|
||||
self,
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test seeking without request body."""
|
||||
response = await authenticated_client.post("/api/v1/player/seek")
|
||||
assert response.status_code == 422
|
||||
@@ -584,7 +585,7 @@ class TestPlayerEndpoints:
|
||||
self,
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test setting volume without request body."""
|
||||
response = await authenticated_client.post("/api/v1/player/volume")
|
||||
assert response.status_code == 422
|
||||
@@ -594,7 +595,7 @@ class TestPlayerEndpoints:
|
||||
self,
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test setting mode without request body."""
|
||||
response = await authenticated_client.post("/api/v1/player/mode")
|
||||
assert response.status_code == 422
|
||||
@@ -605,7 +606,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test playing sound with negative index."""
|
||||
mock_player_service.play.side_effect = ValueError("Invalid sound index")
|
||||
|
||||
@@ -621,7 +622,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test seeking to position zero."""
|
||||
response = await authenticated_client.post(
|
||||
"/api/v1/player/seek",
|
||||
@@ -640,7 +641,7 @@ class TestPlayerEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_player_service,
|
||||
):
|
||||
) -> None:
|
||||
"""Test setting volume with boundary values."""
|
||||
# Test minimum volume
|
||||
response = await authenticated_client.post(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Tests for playlist API endpoints."""
|
||||
# ruff: noqa: ARG002, PLR2004, E501, PLC0415
|
||||
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Tests for socket API endpoints."""
|
||||
# ruff: noqa: ARG002, PLR2004, ANN001, ANN201
|
||||
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
@@ -27,7 +28,7 @@ class TestSocketEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_socket_manager,
|
||||
):
|
||||
) -> None:
|
||||
"""Test getting socket status for authenticated user."""
|
||||
response = await authenticated_client.get("/api/v1/socket/status")
|
||||
|
||||
@@ -42,7 +43,7 @@ class TestSocketEndpoints:
|
||||
assert isinstance(data["connected"], bool)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_socket_status_unauthenticated(self, client: AsyncClient):
|
||||
async def test_get_socket_status_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test getting socket status without authentication."""
|
||||
response = await client.get("/api/v1/socket/status")
|
||||
assert response.status_code == 401
|
||||
@@ -53,7 +54,7 @@ class TestSocketEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_socket_manager,
|
||||
):
|
||||
) -> None:
|
||||
"""Test sending message to specific user successfully."""
|
||||
target_user_id = 2
|
||||
message = "Hello there!"
|
||||
@@ -87,7 +88,7 @@ class TestSocketEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_socket_manager,
|
||||
):
|
||||
) -> None:
|
||||
"""Test sending message to user who is not connected."""
|
||||
target_user_id = 999
|
||||
message = "Hello there!"
|
||||
@@ -108,7 +109,7 @@ class TestSocketEndpoints:
|
||||
assert data["message"] == "User not connected"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_send_message_unauthenticated(self, client: AsyncClient):
|
||||
async def test_send_message_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test sending message without authentication."""
|
||||
response = await client.post(
|
||||
"/api/v1/socket/send-message",
|
||||
@@ -122,7 +123,7 @@ class TestSocketEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_socket_manager,
|
||||
):
|
||||
) -> None:
|
||||
"""Test broadcasting message to all users successfully."""
|
||||
message = "Important announcement!"
|
||||
|
||||
@@ -148,7 +149,7 @@ class TestSocketEndpoints:
|
||||
)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_broadcast_message_unauthenticated(self, client: AsyncClient):
|
||||
async def test_broadcast_message_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test broadcasting message without authentication."""
|
||||
response = await client.post(
|
||||
"/api/v1/socket/broadcast",
|
||||
@@ -159,7 +160,7 @@ class TestSocketEndpoints:
|
||||
@pytest.mark.asyncio
|
||||
async def test_send_message_missing_parameters(
|
||||
self, authenticated_client: AsyncClient, authenticated_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test sending message with missing parameters."""
|
||||
# Missing target_user_id
|
||||
response = await authenticated_client.post(
|
||||
@@ -178,7 +179,7 @@ class TestSocketEndpoints:
|
||||
@pytest.mark.asyncio
|
||||
async def test_broadcast_message_missing_parameters(
|
||||
self, authenticated_client: AsyncClient, authenticated_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test broadcasting message with missing parameters."""
|
||||
response = await authenticated_client.post("/api/v1/socket/broadcast")
|
||||
assert response.status_code == 422
|
||||
@@ -186,7 +187,7 @@ class TestSocketEndpoints:
|
||||
@pytest.mark.asyncio
|
||||
async def test_send_message_invalid_user_id(
|
||||
self, authenticated_client: AsyncClient, authenticated_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test sending message with invalid user ID."""
|
||||
response = await authenticated_client.post(
|
||||
"/api/v1/socket/send-message",
|
||||
@@ -200,7 +201,7 @@ class TestSocketEndpoints:
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
mock_socket_manager,
|
||||
):
|
||||
) -> None:
|
||||
"""Test that socket status correctly shows if user is connected."""
|
||||
# Test when user is connected
|
||||
mock_socket_manager.get_connected_users.return_value = [
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
"""Tests for sound API endpoints."""
|
||||
# ruff: noqa: ARG002, PLR2004, E501, PLC0415, ANN001, ANN202
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
from httpx import ASGITransport, AsyncClient
|
||||
|
||||
from app.models.user import User
|
||||
from app.services.sound_normalizer import NormalizationResults
|
||||
from app.services.sound_scanner import ScanResults
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from app.services.sound_normalizer import NormalizationResults
|
||||
from app.services.sound_scanner import ScanResults
|
||||
|
||||
|
||||
class TestSoundEndpoints:
|
||||
@@ -18,7 +22,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
authenticated_admin_client: AsyncClient,
|
||||
admin_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test successful sound scanning."""
|
||||
# Mock the scanner service to return successful results
|
||||
mock_results: ScanResults = {
|
||||
@@ -95,7 +99,7 @@ class TestSoundEndpoints:
|
||||
assert results["files"][2]["status"] == "deleted"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_scan_sounds_unauthenticated(self, client: AsyncClient):
|
||||
async def test_scan_sounds_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test scanning sounds without authentication."""
|
||||
response = await client.post("/api/v1/sounds/scan")
|
||||
|
||||
@@ -108,7 +112,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
test_app,
|
||||
test_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test scanning sounds with non-admin user."""
|
||||
from app.core.dependencies import get_current_active_user_flexible
|
||||
|
||||
@@ -142,7 +146,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
test_app,
|
||||
admin_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test scanning sounds with admin user."""
|
||||
from app.core.dependencies import get_current_active_user_flexible
|
||||
|
||||
@@ -189,7 +193,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
authenticated_admin_client: AsyncClient,
|
||||
admin_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test scanning sounds when service raises an error."""
|
||||
with patch(
|
||||
"app.services.sound_scanner.SoundScannerService.scan_soundboard_directory",
|
||||
@@ -208,7 +212,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
authenticated_admin_client: AsyncClient,
|
||||
admin_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test successful custom directory scanning."""
|
||||
mock_results: ScanResults = {
|
||||
"scanned": 2,
|
||||
@@ -272,7 +276,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
authenticated_admin_client: AsyncClient,
|
||||
admin_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test custom directory scanning with default sound type."""
|
||||
mock_results: ScanResults = {
|
||||
"scanned": 1,
|
||||
@@ -304,7 +308,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
authenticated_admin_client: AsyncClient,
|
||||
admin_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test custom directory scanning with invalid path."""
|
||||
with patch(
|
||||
"app.services.sound_scanner.SoundScannerService.scan_directory",
|
||||
@@ -322,7 +326,7 @@ class TestSoundEndpoints:
|
||||
assert "Directory does not exist" in data["detail"]
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_scan_custom_directory_unauthenticated(self, client: AsyncClient):
|
||||
async def test_scan_custom_directory_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test custom directory scanning without authentication."""
|
||||
response = await client.post(
|
||||
"/api/v1/sounds/scan/custom", params={"directory": "/some/path"},
|
||||
@@ -337,7 +341,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
test_app,
|
||||
test_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test custom directory scanning with non-admin user."""
|
||||
from app.core.dependencies import get_current_active_user_flexible
|
||||
|
||||
@@ -374,7 +378,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
authenticated_admin_client: AsyncClient,
|
||||
admin_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test custom directory scanning when service raises an error."""
|
||||
with patch(
|
||||
"app.services.sound_scanner.SoundScannerService.scan_directory",
|
||||
@@ -395,7 +399,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
authenticated_admin_client: AsyncClient,
|
||||
admin_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test scanning with some errors in results."""
|
||||
mock_results: ScanResults = {
|
||||
"scanned": 3,
|
||||
@@ -467,7 +471,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
authenticated_admin_client: AsyncClient,
|
||||
admin_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test that endpoint response has correct structure."""
|
||||
mock_results: ScanResults = {
|
||||
"scanned": 0,
|
||||
@@ -519,7 +523,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
authenticated_admin_client: AsyncClient,
|
||||
admin_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test successful normalization of all sounds."""
|
||||
mock_results: NormalizationResults = {
|
||||
"processed": 3,
|
||||
@@ -597,7 +601,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
authenticated_admin_client: AsyncClient,
|
||||
admin_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test normalization with force parameter."""
|
||||
mock_results: NormalizationResults = {
|
||||
"processed": 1,
|
||||
@@ -626,7 +630,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
authenticated_admin_client: AsyncClient,
|
||||
admin_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test normalization with one_pass parameter."""
|
||||
mock_results: NormalizationResults = {
|
||||
"processed": 1,
|
||||
@@ -651,7 +655,7 @@ class TestSoundEndpoints:
|
||||
mock_normalize.assert_called_once_with(force=False, one_pass=True)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_normalize_all_sounds_unauthenticated(self, client: AsyncClient):
|
||||
async def test_normalize_all_sounds_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test normalizing sounds without authentication."""
|
||||
response = await client.post("/api/v1/sounds/normalize/all")
|
||||
|
||||
@@ -664,7 +668,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
test_app,
|
||||
test_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test normalizing sounds with non-admin user."""
|
||||
from app.core.dependencies import get_current_active_user_flexible
|
||||
|
||||
@@ -699,7 +703,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
authenticated_admin_client: AsyncClient,
|
||||
admin_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test normalization when service raises an error."""
|
||||
with patch(
|
||||
"app.services.sound_normalizer.SoundNormalizerService.normalize_all_sounds",
|
||||
@@ -720,7 +724,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
authenticated_admin_client: AsyncClient,
|
||||
admin_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test successful normalization by sound type."""
|
||||
mock_results: NormalizationResults = {
|
||||
"processed": 2,
|
||||
@@ -787,7 +791,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
authenticated_admin_client: AsyncClient,
|
||||
admin_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test normalization with invalid sound type."""
|
||||
response = await authenticated_admin_client.post(
|
||||
"/api/v1/sounds/normalize/type/INVALID",
|
||||
@@ -803,7 +807,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
authenticated_admin_client: AsyncClient,
|
||||
admin_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test normalization by type with force and one_pass parameters."""
|
||||
mock_results: NormalizationResults = {
|
||||
"processed": 1,
|
||||
@@ -835,7 +839,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
authenticated_admin_client: AsyncClient,
|
||||
admin_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test successful normalization of a specific sound."""
|
||||
# Mock the sound
|
||||
mock_sound = type(
|
||||
@@ -894,7 +898,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
authenticated_admin_client: AsyncClient,
|
||||
admin_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test normalization of non-existent sound."""
|
||||
with patch(
|
||||
"app.repositories.sound.SoundRepository.get_by_id",
|
||||
@@ -914,7 +918,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
authenticated_admin_client: AsyncClient,
|
||||
admin_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test normalization when the sound normalization fails."""
|
||||
# Mock the sound
|
||||
mock_sound = type(
|
||||
@@ -966,7 +970,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
authenticated_admin_client: AsyncClient,
|
||||
admin_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test sound normalization with force and one_pass parameters."""
|
||||
# Mock the sound
|
||||
mock_sound = type(
|
||||
@@ -1013,15 +1017,15 @@ class TestSoundEndpoints:
|
||||
|
||||
# Verify parameters were passed to normalize_sound
|
||||
call_args = mock_normalize_sound.call_args
|
||||
assert call_args[1]["force"] == True
|
||||
assert call_args[1]["one_pass"] == True
|
||||
assert call_args[1]["force"]
|
||||
assert call_args[1]["one_pass"]
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_normalize_sound_by_id_skipped(
|
||||
self,
|
||||
authenticated_admin_client: AsyncClient,
|
||||
admin_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test normalization when sound is already normalized and not forced."""
|
||||
# Mock the sound
|
||||
mock_sound = type(
|
||||
@@ -1071,7 +1075,7 @@ class TestSoundEndpoints:
|
||||
assert data["reason"] == "already normalized"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_normalize_sound_by_id_unauthenticated(self, client: AsyncClient):
|
||||
async def test_normalize_sound_by_id_unauthenticated(self, client: AsyncClient) -> None:
|
||||
"""Test normalizing a specific sound without authentication."""
|
||||
response = await client.post("/api/v1/sounds/normalize/42")
|
||||
|
||||
@@ -1084,7 +1088,7 @@ class TestSoundEndpoints:
|
||||
self,
|
||||
test_app,
|
||||
test_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test normalizing a specific sound with non-admin user."""
|
||||
from app.core.dependencies import get_current_active_user_flexible
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Tests for VLC player API endpoints."""
|
||||
# ruff: noqa: ARG002, PLR2004, E501
|
||||
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
@@ -20,7 +21,7 @@ class TestVLCEndpoints:
|
||||
test_app: FastAPI,
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test successful sound playback via VLC."""
|
||||
# Set up mocks
|
||||
mock_vlc_service = AsyncMock()
|
||||
@@ -73,7 +74,7 @@ class TestVLCEndpoints:
|
||||
test_app: FastAPI,
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test VLC playback when sound is not found."""
|
||||
# Set up mocks
|
||||
mock_vlc_service = AsyncMock()
|
||||
@@ -106,7 +107,7 @@ class TestVLCEndpoints:
|
||||
test_app: FastAPI,
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test VLC playback when VLC launch fails."""
|
||||
# Set up mocks
|
||||
mock_vlc_service = AsyncMock()
|
||||
@@ -153,7 +154,7 @@ class TestVLCEndpoints:
|
||||
test_app: FastAPI,
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test VLC playback when service raises an exception."""
|
||||
# Set up mocks
|
||||
mock_vlc_service = AsyncMock()
|
||||
@@ -184,7 +185,7 @@ class TestVLCEndpoints:
|
||||
async def test_play_sound_with_vlc_unauthenticated(
|
||||
self,
|
||||
client: AsyncClient,
|
||||
):
|
||||
) -> None:
|
||||
"""Test VLC playback without authentication."""
|
||||
response = await client.post("/api/v1/sounds/vlc/play/1")
|
||||
assert response.status_code == 401
|
||||
@@ -195,7 +196,7 @@ class TestVLCEndpoints:
|
||||
test_app: FastAPI,
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test successful stopping of all VLC instances."""
|
||||
# Set up mock
|
||||
mock_vlc_service = AsyncMock()
|
||||
@@ -234,7 +235,7 @@ class TestVLCEndpoints:
|
||||
test_app: FastAPI,
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test stopping VLC instances when none are running."""
|
||||
# Set up mock
|
||||
mock_vlc_service = AsyncMock()
|
||||
@@ -268,7 +269,7 @@ class TestVLCEndpoints:
|
||||
test_app: FastAPI,
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test stopping VLC instances with partial success."""
|
||||
# Set up mock
|
||||
mock_vlc_service = AsyncMock()
|
||||
@@ -303,7 +304,7 @@ class TestVLCEndpoints:
|
||||
test_app: FastAPI,
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test stopping VLC instances when service fails."""
|
||||
# Set up mock
|
||||
mock_vlc_service = AsyncMock()
|
||||
@@ -337,7 +338,7 @@ class TestVLCEndpoints:
|
||||
test_app: FastAPI,
|
||||
authenticated_client: AsyncClient,
|
||||
authenticated_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test stopping VLC instances when service raises an exception."""
|
||||
# Set up mock to raise an exception
|
||||
mock_vlc_service = AsyncMock()
|
||||
@@ -360,7 +361,7 @@ class TestVLCEndpoints:
|
||||
async def test_stop_all_vlc_instances_unauthenticated(
|
||||
self,
|
||||
client: AsyncClient,
|
||||
):
|
||||
) -> None:
|
||||
"""Test stopping VLC instances without authentication."""
|
||||
response = await client.post("/api/v1/sounds/vlc/stop-all")
|
||||
assert response.status_code == 401
|
||||
@@ -371,7 +372,7 @@ class TestVLCEndpoints:
|
||||
test_app: FastAPI,
|
||||
authenticated_admin_client: AsyncClient,
|
||||
admin_user: User,
|
||||
):
|
||||
) -> None:
|
||||
"""Test VLC endpoints work with admin user."""
|
||||
# Set up mocks
|
||||
mock_vlc_service = AsyncMock()
|
||||
|
||||
Reference in New Issue
Block a user