Refactor test cases for improved readability and consistency
- Adjusted function signatures in various test files to enhance clarity by aligning parameters. - Updated patching syntax for better readability across test cases. - Improved formatting and spacing in test assertions and mock setups. - Ensured consistent use of async/await patterns in async test functions. - Enhanced comments for better understanding of test intentions.
This commit is contained in:
@@ -407,7 +407,8 @@ class TestPlaylistRepository:
|
||||
|
||||
# Test the repository method
|
||||
playlist_sound = await playlist_repository.add_sound_to_playlist(
|
||||
playlist_id, sound_id,
|
||||
playlist_id,
|
||||
sound_id,
|
||||
)
|
||||
|
||||
assert playlist_sound.playlist_id == playlist_id
|
||||
@@ -472,7 +473,9 @@ class TestPlaylistRepository:
|
||||
|
||||
# Test the repository method
|
||||
playlist_sound = await playlist_repository.add_sound_to_playlist(
|
||||
playlist_id, sound_id, position=5,
|
||||
playlist_id,
|
||||
sound_id,
|
||||
position=5,
|
||||
)
|
||||
|
||||
assert playlist_sound.position == TEST_POSITION
|
||||
@@ -535,17 +538,20 @@ class TestPlaylistRepository:
|
||||
|
||||
# Verify it was added
|
||||
assert await playlist_repository.is_sound_in_playlist(
|
||||
playlist_id, sound_id,
|
||||
playlist_id,
|
||||
sound_id,
|
||||
)
|
||||
|
||||
# Remove the sound
|
||||
await playlist_repository.remove_sound_from_playlist(
|
||||
playlist_id, sound_id,
|
||||
playlist_id,
|
||||
sound_id,
|
||||
)
|
||||
|
||||
# Verify it was removed
|
||||
assert not await playlist_repository.is_sound_in_playlist(
|
||||
playlist_id, sound_id,
|
||||
playlist_id,
|
||||
sound_id,
|
||||
)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -732,7 +738,8 @@ class TestPlaylistRepository:
|
||||
|
||||
# Initially not in playlist
|
||||
assert not await playlist_repository.is_sound_in_playlist(
|
||||
playlist_id, sound_id,
|
||||
playlist_id,
|
||||
sound_id,
|
||||
)
|
||||
|
||||
# Add sound
|
||||
@@ -740,7 +747,8 @@ class TestPlaylistRepository:
|
||||
|
||||
# Now in playlist
|
||||
assert await playlist_repository.is_sound_in_playlist(
|
||||
playlist_id, sound_id,
|
||||
playlist_id,
|
||||
sound_id,
|
||||
)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -794,16 +802,21 @@ class TestPlaylistRepository:
|
||||
|
||||
# Add sounds to playlist
|
||||
await playlist_repository.add_sound_to_playlist(
|
||||
playlist_id, sound1_id, position=0,
|
||||
playlist_id,
|
||||
sound1_id,
|
||||
position=0,
|
||||
)
|
||||
await playlist_repository.add_sound_to_playlist(
|
||||
playlist_id, sound2_id, position=1,
|
||||
playlist_id,
|
||||
sound2_id,
|
||||
position=1,
|
||||
)
|
||||
|
||||
# Reorder sounds - use different positions to avoid constraint issues
|
||||
sound_positions = [(sound1_id, 10), (sound2_id, 5)]
|
||||
await playlist_repository.reorder_playlist_sounds(
|
||||
playlist_id, sound_positions,
|
||||
playlist_id,
|
||||
sound_positions,
|
||||
)
|
||||
|
||||
# Verify new order
|
||||
@@ -863,10 +876,14 @@ class TestPlaylistRepository:
|
||||
|
||||
# Add sounds to playlist at positions 0 and 1
|
||||
await playlist_repository.add_sound_to_playlist(
|
||||
playlist_id, sound1_id, position=0,
|
||||
playlist_id,
|
||||
sound1_id,
|
||||
position=0,
|
||||
)
|
||||
await playlist_repository.add_sound_to_playlist(
|
||||
playlist_id, sound2_id, position=1,
|
||||
playlist_id,
|
||||
sound2_id,
|
||||
position=1,
|
||||
)
|
||||
|
||||
# Verify initial order
|
||||
@@ -878,7 +895,8 @@ class TestPlaylistRepository:
|
||||
# Swap positions - this used to cause unique constraint violation
|
||||
sound_positions = [(sound1_id, 1), (sound2_id, 0)]
|
||||
await playlist_repository.reorder_playlist_sounds(
|
||||
playlist_id, sound_positions,
|
||||
playlist_id,
|
||||
sound_positions,
|
||||
)
|
||||
|
||||
# Verify swapped order
|
||||
|
||||
Reference in New Issue
Block a user