refactor: Update player seek functionality to use consistent position field across schemas and services
All checks were successful
Backend CI / test (push) Successful in 4m5s
All checks were successful
Backend CI / test (push) Successful in 4m5s
This commit is contained in:
@@ -278,17 +278,17 @@ class TestPlayerEndpoints:
|
||||
mock_player_service,
|
||||
):
|
||||
"""Test seeking to position successfully."""
|
||||
position_ms = 5000
|
||||
position = 5000
|
||||
response = await authenticated_client.post(
|
||||
"/api/v1/player/seek",
|
||||
json={"position_ms": position_ms},
|
||||
json={"position": position},
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["message"] == f"Seeked to position {position_ms}ms"
|
||||
assert data["message"] == f"Seeked to position {position}ms"
|
||||
|
||||
mock_player_service.seek.assert_called_once_with(position_ms)
|
||||
mock_player_service.seek.assert_called_once_with(position)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_seek_invalid_position(
|
||||
@@ -300,7 +300,7 @@ class TestPlayerEndpoints:
|
||||
"""Test seeking with invalid position."""
|
||||
response = await authenticated_client.post(
|
||||
"/api/v1/player/seek",
|
||||
json={"position_ms": -1000}, # Negative position
|
||||
json={"position": -1000}, # Negative position
|
||||
)
|
||||
|
||||
assert response.status_code == 422 # Validation error
|
||||
@@ -310,7 +310,7 @@ class TestPlayerEndpoints:
|
||||
"""Test seeking without authentication."""
|
||||
response = await client.post(
|
||||
"/api/v1/player/seek",
|
||||
json={"position_ms": 5000},
|
||||
json={"position": 5000},
|
||||
)
|
||||
assert response.status_code == 401
|
||||
|
||||
@@ -326,7 +326,7 @@ class TestPlayerEndpoints:
|
||||
|
||||
response = await authenticated_client.post(
|
||||
"/api/v1/player/seek",
|
||||
json={"position_ms": 5000},
|
||||
json={"position": 5000},
|
||||
)
|
||||
|
||||
assert response.status_code == 500
|
||||
@@ -516,8 +516,8 @@ class TestPlayerEndpoints:
|
||||
"status": PlayerStatus.PLAYING.value,
|
||||
"mode": PlayerMode.CONTINUOUS.value,
|
||||
"volume": 50,
|
||||
"position_ms": 5000,
|
||||
"duration_ms": 30000,
|
||||
"position": 5000,
|
||||
"duration": 30000,
|
||||
"index": 0,
|
||||
"current_sound": {
|
||||
"id": 1,
|
||||
@@ -625,7 +625,7 @@ class TestPlayerEndpoints:
|
||||
"""Test seeking to position zero."""
|
||||
response = await authenticated_client.post(
|
||||
"/api/v1/player/seek",
|
||||
json={"position_ms": 0},
|
||||
json={"position": 0},
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
@@ -65,14 +65,13 @@ class TestPlayerState:
|
||||
assert result["status"] == "playing"
|
||||
assert result["mode"] == "loop"
|
||||
assert result["volume"] == 75
|
||||
assert result["current_sound_id"] == 1
|
||||
assert result["current_sound_index"] == 0
|
||||
assert result["current_sound_position"] == 5000
|
||||
assert result["current_sound_duration"] == 30000
|
||||
assert result["playlist_id"] == 1
|
||||
assert result["playlist_name"] == "Test Playlist"
|
||||
assert result["playlist_length"] == 5
|
||||
assert result["playlist_duration"] == 150000
|
||||
assert result["position"] == 5000
|
||||
assert result["duration"] == 30000
|
||||
assert result["index"] == 0
|
||||
assert result["playlist"]["id"] == 1
|
||||
assert result["playlist"]["name"] == "Test Playlist"
|
||||
assert result["playlist"]["length"] == 5
|
||||
assert result["playlist"]["duration"] == 150000
|
||||
|
||||
def test_serialize_sound_with_sound_object(self):
|
||||
"""Test serializing a sound object."""
|
||||
|
||||
Reference in New Issue
Block a user