Add comprehensive tests for player API endpoints and player service functionality
- Implemented tests for player API endpoints including play, pause, stop, next, previous, seek, set volume, set mode, reload playlist, and get state. - Added mock player service for testing API interactions. - Created tests for player service methods including play, pause, stop playback, next, previous, seek, set volume, set mode, and reload playlist. - Ensured proper handling of success, error, and edge cases in both API and service tests. - Verified state management and serialization in player state tests.
This commit is contained in:
@@ -329,6 +329,10 @@ class TestExtractionService:
|
||||
hash="test_hash",
|
||||
is_normalized=False,
|
||||
)
|
||||
sound_id = 1
|
||||
|
||||
# Mock sound repository to return the sound
|
||||
extraction_service.sound_repo.get_by_id = AsyncMock(return_value=sound)
|
||||
|
||||
mock_normalizer = Mock()
|
||||
mock_normalizer.normalize_sound = AsyncMock(
|
||||
@@ -340,7 +344,8 @@ class TestExtractionService:
|
||||
return_value=mock_normalizer,
|
||||
):
|
||||
# Should not raise exception
|
||||
await extraction_service._normalize_sound(sound)
|
||||
await extraction_service._normalize_sound(sound_id)
|
||||
extraction_service.sound_repo.get_by_id.assert_called_once_with(sound_id)
|
||||
mock_normalizer.normalize_sound.assert_called_once_with(sound)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -356,6 +361,10 @@ class TestExtractionService:
|
||||
hash="test_hash",
|
||||
is_normalized=False,
|
||||
)
|
||||
sound_id = 1
|
||||
|
||||
# Mock sound repository to return the sound
|
||||
extraction_service.sound_repo.get_by_id = AsyncMock(return_value=sound)
|
||||
|
||||
mock_normalizer = Mock()
|
||||
mock_normalizer.normalize_sound = AsyncMock(
|
||||
@@ -367,7 +376,8 @@ class TestExtractionService:
|
||||
return_value=mock_normalizer,
|
||||
):
|
||||
# Should not raise exception even on failure
|
||||
await extraction_service._normalize_sound(sound)
|
||||
await extraction_service._normalize_sound(sound_id)
|
||||
extraction_service.sound_repo.get_by_id.assert_called_once_with(sound_id)
|
||||
mock_normalizer.normalize_sound.assert_called_once_with(sound)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user