fix: Lint fixes of last tests
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user