aboutsummaryrefslogtreecommitdiffstats
path: root/solo-tool-project/test
diff options
context:
space:
mode:
authorEddy Pedroni <epedroni@pm.me>2025-02-22 08:17:29 +0100
committerEddy Pedroni <epedroni@pm.me>2025-02-22 08:17:29 +0100
commiteaec524a233c9ee11023f21d430bcbc2f4d5a17e (patch)
tree9028a1879aaa07c373bd51198f6aed60eb6dfd1b /solo-tool-project/test
parentb676f88b21ef8046dcd3d9dac4b270007f2b959a (diff)
Moved nextSong and previousSong to SoloToolController
Diffstat (limited to 'solo-tool-project/test')
-rw-r--r--solo-tool-project/test/midi_launchpad_mini_integrationtest.py2
-rw-r--r--solo-tool-project/test/playlist_unittest.py45
-rw-r--r--solo-tool-project/test/solo_tool_controller_integrationtest.py86
-rw-r--r--solo-tool-project/test/solo_tool_integrationtest.py39
4 files changed, 88 insertions, 84 deletions
diff --git a/solo-tool-project/test/midi_launchpad_mini_integrationtest.py b/solo-tool-project/test/midi_launchpad_mini_integrationtest.py
index 8fd09bb..b0105a9 100644
--- a/solo-tool-project/test/midi_launchpad_mini_integrationtest.py
+++ b/solo-tool-project/test/midi_launchpad_mini_integrationtest.py
@@ -402,7 +402,7 @@ def test_playingFeedbackWhenChangingSong(uut, midiWrapperMock, soloTool, playerM
assert playerMock.state == PlayerMock.PLAYING
assert midiWrapperMock.getLatestMessage() == (playPauseButton, LED_GREEN, 0)
- soloTool.nextSong()
+ soloTool.setSong(1)
assert playerMock.state == PlayerMock.STOPPED
assert midiWrapperMock.getLatestMessage() == (playPauseButton, LED_YELLOW, 0)
diff --git a/solo-tool-project/test/playlist_unittest.py b/solo-tool-project/test/playlist_unittest.py
index 842ce51..4b0186b 100644
--- a/solo-tool-project/test/playlist_unittest.py
+++ b/solo-tool-project/test/playlist_unittest.py
@@ -101,48 +101,3 @@ def test_clearPlaylist():
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
diff --git a/solo-tool-project/test/solo_tool_controller_integrationtest.py b/solo-tool-project/test/solo_tool_controller_integrationtest.py
new file mode 100644
index 0000000..c161c70
--- /dev/null
+++ b/solo-tool-project/test/solo_tool_controller_integrationtest.py
@@ -0,0 +1,86 @@
+import pathlib
+import shutil
+import pytest
+
+from solo_tool.solo_tool_controller import SoloToolController
+from solo_tool.solo_tool import SoloTool
+
+@pytest.fixture
+def prepared_tmp_path(tmp_path):
+ testFiles = [
+ "test.flac",
+ "test.mp3",
+ "test_session.json"
+ ]
+ for f in testFiles:
+ shutil.copy(pathlib.Path(f), tmp_path)
+ return tmp_path
+
+@pytest.fixture
+def soloTool(prepared_tmp_path):
+ st = SoloTool()
+ st.loadSession(prepared_tmp_path / "test_session.json")
+ return st
+
+@pytest.fixture
+def uut(soloTool):
+ return SoloToolController(soloTool)
+
+def test_previousSong(uut, soloTool):
+ called = False
+ receivedValue = None
+ def callback(value):
+ nonlocal called, receivedValue
+ called = True
+ receivedValue = value
+
+ soloTool.registerCurrentSongCallback(callback)
+
+ soloTool.getCurrentSong() == None
+ assert not called
+
+ uut.previousSong()
+ soloTool.getCurrentSong() == 0
+ assert called
+ assert receivedValue == 0
+ called = False
+
+ uut.previousSong()
+ soloTool.getCurrentSong() == 0
+ assert not called
+
+ soloTool.setSong(1)
+ uut.previousSong()
+ soloTool.getCurrentSong() == 0
+ assert called
+ assert receivedValue == 0
+ called = False
+
+def test_nextSong(uut, soloTool):
+ called = False
+ receivedValue = None
+ def callback(value):
+ nonlocal called, receivedValue
+ called = True
+ receivedValue = value
+
+ soloTool.registerCurrentSongCallback(callback)
+
+ soloTool.getCurrentSong() == None
+ assert not called
+
+ uut.nextSong()
+ soloTool.getCurrentSong() == 0
+ assert called
+ assert receivedValue == 0
+ called = False
+
+ uut.nextSong()
+ soloTool.getCurrentSong() == 1
+ assert called
+ assert receivedValue == 1
+ called = False
+
+ uut.nextSong()
+ soloTool.getCurrentSong() == 1
+ assert not called
diff --git a/solo-tool-project/test/solo_tool_integrationtest.py b/solo-tool-project/test/solo_tool_integrationtest.py
index 5903abf..ee33468 100644
--- a/solo-tool-project/test/solo_tool_integrationtest.py
+++ b/solo-tool-project/test/solo_tool_integrationtest.py
@@ -72,28 +72,7 @@ def test_addAndSetSongs(uut, mockPlayer):
for i, s in enumerate(songs):
uut.setSong(i)
assert mockPlayer.currentSong == songs[i]
-
-def test_nextAndPreviousSong(uut, mockPlayer):
- songs = [
- "test.flac",
- "test.mp3"
- ]
-
- for s in songs:
- uut.addSong(s)
- assert mockPlayer.currentSong == None
-
- uut.nextSong()
- assert mockPlayer.currentSong == songs[0]
-
- uut.previousSong()
- assert mockPlayer.currentSong == songs[0]
-
- uut.nextSong()
- assert mockPlayer.currentSong == songs[1]
-
- uut.nextSong()
- assert mockPlayer.currentSong == songs[1]
+ assert uut.getCurrentSong() == i
def test_addAndSetAbLimits(uut, mockPlayer):
song = "test.flac"
@@ -495,22 +474,6 @@ def test_currentSongNotification(uut):
assert receivedValue == 1
called = False
- uut.previousSong()
- assert called
- assert receivedValue == 0
- called = False
-
- uut.previousSong()
- assert not called
-
- uut.nextSong()
- assert called
- assert receivedValue == 1
- called = False
-
- uut.nextSong()
- assert not called
-
def test_currentAbNotification(uut):
called = False
receivedValue = None