feat: Update player state tests to include previous volume and adjust volume assertions
This commit is contained in:
@@ -516,6 +516,7 @@ class TestPlayerEndpoints:
|
|||||||
"status": PlayerStatus.PLAYING.value,
|
"status": PlayerStatus.PLAYING.value,
|
||||||
"mode": PlayerMode.CONTINUOUS.value,
|
"mode": PlayerMode.CONTINUOUS.value,
|
||||||
"volume": 50,
|
"volume": 50,
|
||||||
|
"previous_volume": 80,
|
||||||
"position": 5000,
|
"position": 5000,
|
||||||
"duration": 30000,
|
"duration": 30000,
|
||||||
"index": 0,
|
"index": 0,
|
||||||
|
|||||||
@@ -337,7 +337,7 @@ class TestSoundEndpoints:
|
|||||||
"""Test getting sounds with authentication."""
|
"""Test getting sounds with authentication."""
|
||||||
from app.models.sound import Sound
|
from app.models.sound import Sound
|
||||||
|
|
||||||
with patch("app.repositories.sound.SoundRepository.get_by_types") as mock_get:
|
with patch("app.repositories.sound.SoundRepository.search_and_sort") as mock_get:
|
||||||
# Create mock sounds with all required fields
|
# Create mock sounds with all required fields
|
||||||
mock_sound_1 = Sound(
|
mock_sound_1 = Sound(
|
||||||
id=1,
|
id=1,
|
||||||
@@ -383,7 +383,7 @@ class TestSoundEndpoints:
|
|||||||
"""Test getting sounds with type filtering."""
|
"""Test getting sounds with type filtering."""
|
||||||
from app.models.sound import Sound
|
from app.models.sound import Sound
|
||||||
|
|
||||||
with patch("app.repositories.sound.SoundRepository.get_by_types") as mock_get:
|
with patch("app.repositories.sound.SoundRepository.search_and_sort") as mock_get:
|
||||||
# Create mock sound with all required fields
|
# Create mock sound with all required fields
|
||||||
mock_sound = Sound(
|
mock_sound = Sound(
|
||||||
id=1,
|
id=1,
|
||||||
@@ -408,4 +408,5 @@ class TestSoundEndpoints:
|
|||||||
assert len(data["sounds"]) == 1
|
assert len(data["sounds"]) == 1
|
||||||
|
|
||||||
# Verify the repository was called with the correct types
|
# Verify the repository was called with the correct types
|
||||||
mock_get.assert_called_once_with(["SDB"])
|
mock_get.assert_called_once()
|
||||||
|
assert mock_get.call_args.kwargs["sound_types"] == ["SDB"]
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ class TestPlayerState:
|
|||||||
|
|
||||||
assert state.status == PlayerStatus.STOPPED
|
assert state.status == PlayerStatus.STOPPED
|
||||||
assert state.mode == PlayerMode.CONTINUOUS
|
assert state.mode == PlayerMode.CONTINUOUS
|
||||||
assert state.volume == 50
|
assert state.volume == 80
|
||||||
|
assert state.previous_volume == 80
|
||||||
assert state.current_sound_id is None
|
assert state.current_sound_id is None
|
||||||
assert state.current_sound_index is None
|
assert state.current_sound_index is None
|
||||||
assert state.current_sound_position == 0
|
assert state.current_sound_position == 0
|
||||||
@@ -216,7 +217,7 @@ class TestPlayerService:
|
|||||||
assert player_service._loop is not None
|
assert player_service._loop is not None
|
||||||
assert player_service._position_thread is not None
|
assert player_service._position_thread is not None
|
||||||
assert player_service._position_thread.daemon is True
|
assert player_service._position_thread.daemon is True
|
||||||
player_service._player.audio_set_volume.assert_called_once_with(50)
|
player_service._player.audio_set_volume.assert_called_once_with(80)
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_stop_cleans_up_service(self, player_service) -> None:
|
async def test_stop_cleans_up_service(self, player_service) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user