aboutsummaryrefslogtreecommitdiffstats
path: root/playlist_unittest.py
diff options
context:
space:
mode:
authorEddy Pedroni <epedroni@pm.me>2024-11-09 20:35:56 +0100
committerEddy Pedroni <epedroni@pm.me>2024-11-09 20:35:56 +0100
commitcda8197669409689be291660f93cb288ab2d31b3 (patch)
tree81db9b0c7c0491e0737cbffb39af6b935c0dfeb8 /playlist_unittest.py
parenta2257a900d4fffd6f94b73f1c48c62370ed1d684 (diff)
Migrate to project-based structure
Diffstat (limited to 'playlist_unittest.py')
-rw-r--r--playlist_unittest.py148
1 files changed, 0 insertions, 148 deletions
diff --git a/playlist_unittest.py b/playlist_unittest.py
deleted file mode 100644
index 815a05f..0000000
--- a/playlist_unittest.py
+++ /dev/null
@@ -1,148 +0,0 @@
-from playlist import Playlist
-
-def test_addAndSelectOneSong():
- songAddedByUser = "/path/to/song"
- songSetByCallback = None
-
- def testCallback(song):
- nonlocal songSetByCallback
- songSetByCallback = song
-
- uut = Playlist(testCallback)
- uut.addSong(songAddedByUser)
- uut.setCurrentSong(0)
-
- assert songAddedByUser == songSetByCallback
- assert uut.getCurrentSong() == songAddedByUser
- assert uut.getCurrentSongIndex() == 0
- assert uut.getSongs() == [songAddedByUser]
-
-def test_addTwoSongsAndSelectBoth():
- songAddedByUser = ["/path/to/song", "/path/to/second/song"]
- songSetByCallback = None
-
- def testCallback(song):
- nonlocal songSetByCallback
- songSetByCallback = song
-
- uut = Playlist(testCallback)
- uut.addSong(songAddedByUser[0])
- uut.addSong(songAddedByUser[1])
- assert uut.getSongs() == songAddedByUser
-
- uut.setCurrentSong(0)
- assert songAddedByUser[0] == songSetByCallback
- assert uut.getCurrentSong() == songAddedByUser[0]
- assert uut.getCurrentSongIndex() == 0
-
- uut.setCurrentSong(1)
- assert songAddedByUser[1] == songSetByCallback
- assert uut.getCurrentSong() == songAddedByUser[1]
- assert uut.getCurrentSongIndex() == 1
-
-def test_firstAddedSongIsNotSelected():
- songAddedByUser = "/path/to/song"
- songSetByCallback = None
-
- def testCallback(song):
- nonlocal songSetByCallback
- songSetByCallback = song
-
- uut = Playlist(testCallback)
- uut.addSong(songAddedByUser)
-
- assert songSetByCallback == None
- assert uut.getCurrentSong() == None
- assert uut.getCurrentSongIndex() == None
- assert uut.getSongs() == [songAddedByUser]
-
-def test_invalidSongSelection():
- songAddedByUser = "/path/to/song"
- songSetByCallback = None
-
- def testCallback(song):
- nonlocal songSetByCallback
- songSetByCallback = song
-
- uut = Playlist(testCallback)
- assert songSetByCallback == None
- assert uut.getCurrentSong() == None
- assert uut.getCurrentSongIndex() == None
-
- uut.setCurrentSong(10)
- assert songSetByCallback == None
- assert uut.getCurrentSong() == None
- assert uut.getCurrentSongIndex() == None
-
- uut.addSong(songAddedByUser)
- uut.setCurrentSong(10)
- assert songSetByCallback == None
- assert uut.getCurrentSong() == None
- assert uut.getCurrentSongIndex() == None
- assert uut.getSongs() == [songAddedByUser]
-
-def test_clearPlaylist():
- songAddedByUser = ["/path/to/song", "/path/to/second/song"]
-
- def dummy(index):
- pass
-
- uut = Playlist(dummy)
- for s in songAddedByUser:
- uut.addSong(s)
- uut.setCurrentSong(0)
-
- assert uut.getSongs() == songAddedByUser
- assert uut.getCurrentSong() == songAddedByUser[0]
- assert uut.getCurrentSongIndex() == 0
-
- uut.clear()
-
- assert uut.getSongs() == []
- assert uut.getCurrentSong() == None
- assert uut.getCurrentSongIndex() == None
-
-def test_nextSong():
- songAddedByUser = ["/path/to/song", "/path/to/second/song"]
-
- uut = Playlist(lambda index: None)
- for s in songAddedByUser:
- uut.addSong(s)
- assert uut.getCurrentSong() == None
- assert uut.getCurrentSongIndex() == None
-
- uut.nextSong()
- assert uut.getCurrentSong() == songAddedByUser[0]
- assert uut.getCurrentSongIndex() == 0
-
- uut.nextSong()
- assert uut.getCurrentSong() == songAddedByUser[1]
- assert uut.getCurrentSongIndex() == 1
-
- uut.nextSong()
- assert uut.getCurrentSong() == songAddedByUser[1]
- assert uut.getCurrentSongIndex() == 1
-
-def test_previousSong():
- songAddedByUser = ["/path/to/song", "/path/to/second/song"]
-
- uut = Playlist(lambda index: None)
- for s in songAddedByUser:
- uut.addSong(s)
- assert uut.getCurrentSong() == None
- assert uut.getCurrentSongIndex() == None
-
- uut.previousSong()
- assert uut.getCurrentSong() == songAddedByUser[0]
- assert uut.getCurrentSongIndex() == 0
-
- uut.previousSong()
- assert uut.getCurrentSong() == songAddedByUser[0]
- assert uut.getCurrentSongIndex() == 0
-
- uut.setCurrentSong(1)
- assert uut.getCurrentSong() == songAddedByUser[1]
- assert uut.getCurrentSongIndex() == 1
- uut.previousSong()
- assert uut.getCurrentSong() == songAddedByUser[0]
- assert uut.getCurrentSongIndex() == 0