aboutsummaryrefslogtreecommitdiffstats
path: root/solo-tool-project/test/solo_tool_controller_integrationtest.py
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/solo_tool_controller_integrationtest.py
parentb676f88b21ef8046dcd3d9dac4b270007f2b959a (diff)
Moved nextSong and previousSong to SoloToolController
Diffstat (limited to 'solo-tool-project/test/solo_tool_controller_integrationtest.py')
-rw-r--r--solo-tool-project/test/solo_tool_controller_integrationtest.py86
1 files changed, 86 insertions, 0 deletions
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