-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#266 Refactor song loader logic and enhance playlist handling
Reorganized song loader methods for better readability, updated playlist comparison logic, and added detailed logging. Introduced tests for playlist change detection and improved error-handling with custom exceptions. These changes ensure more accurate playlist updates and improved maintainability.
- Loading branch information
Showing
6 changed files
with
147 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# tests/test_song_loader_helper.py | ||
|
||
from modules.servant.song_loader.song_loader_helper import playlist_does_not_changed | ||
|
||
|
||
def test_playlist_does_not_change_identical_sets(): | ||
rsplaylist_request_strings = {"song1", "song2", "song3"} | ||
new_rsplaylist_request_strings = {"song1", "song2", "song3"} | ||
assert playlist_does_not_changed(rsplaylist_request_strings, new_rsplaylist_request_strings) is True | ||
|
||
|
||
def test_playlist_does_not_change_identical_sets_different_order(): | ||
rsplaylist_request_strings = {"song1", "song2", "song3"} | ||
new_rsplaylist_request_strings = {"song2", "song1", "song3"} | ||
assert playlist_does_not_changed(rsplaylist_request_strings, new_rsplaylist_request_strings) is True | ||
|
||
|
||
def test_playlist_changes_differing_sets(): | ||
rsplaylist_request_strings = {"song1", "song2", "song3"} | ||
new_rsplaylist_request_strings = {"song1", "song2", "song4"} | ||
assert playlist_does_not_changed(rsplaylist_request_strings, new_rsplaylist_request_strings) is False | ||
|
||
|
||
def test_playlist_changes_differing_sets_less_new(): | ||
rsplaylist_request_strings = {"song1", "song2", "song3"} | ||
new_rsplaylist_request_strings = {"song1", "song2"} | ||
assert playlist_does_not_changed(rsplaylist_request_strings, new_rsplaylist_request_strings) is False | ||
|
||
|
||
def test_playlist_changes_differing_sets_more_new(): | ||
rsplaylist_request_strings = {"song1", "song2"} | ||
new_rsplaylist_request_strings = {"song1", "song2", "song3"} | ||
assert playlist_does_not_changed(rsplaylist_request_strings, new_rsplaylist_request_strings) is False | ||
|
||
|
||
def test_playlist_changes_empty_vs_non_empty(): | ||
rsplaylist_request_strings = set() | ||
new_rsplaylist_request_strings = {"song1", "song2", "song3"} | ||
assert playlist_does_not_changed(rsplaylist_request_strings, new_rsplaylist_request_strings) is False | ||
|
||
|
||
def test_playlist_changes_non_empty_vs_empty(): | ||
rsplaylist_request_strings = {"song1", "song2", "song3"} | ||
new_rsplaylist_request_strings = set() | ||
assert playlist_does_not_changed(rsplaylist_request_strings, new_rsplaylist_request_strings) is False | ||
|
||
|
||
def test_playlist_does_not_change_both_empty(): | ||
rsplaylist_request_strings = set() | ||
new_rsplaylist_request_strings = set() | ||
assert playlist_does_not_changed(rsplaylist_request_strings, new_rsplaylist_request_strings) is True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters