From 876071a7a41ee4a1f579739b242a00058bdc160d Mon Sep 17 00:00:00 2001
From: Eddy Pedroni <epedroni@pm.me>
Date: Tue, 25 Feb 2025 13:04:44 +0100
Subject: Refactor song selection tests, change behaviour so first added song
 is automatically selected

---
 .../test/midi_launchpad_mini_integrationtest.py    |  3 -
 .../test/solo_tool_integrationtest.py              | 87 +---------------------
 2 files changed, 2 insertions(+), 88 deletions(-)

(limited to 'solo-tool-project/test')

diff --git a/solo-tool-project/test/midi_launchpad_mini_integrationtest.py b/solo-tool-project/test/midi_launchpad_mini_integrationtest.py
index 9e8c92e..642733d 100644
--- a/solo-tool-project/test/midi_launchpad_mini_integrationtest.py
+++ b/solo-tool-project/test/midi_launchpad_mini_integrationtest.py
@@ -138,10 +138,7 @@ def test_previousAndNextSongButtons(uut, midiWrapperMock, soloTool, playerMock):
         soloTool.addSong(s)
     uut.connect()
 
-    assert playerMock.currentSong == None
-    midiWrapperMock.simulateInput(nextSongButton)
     assert playerMock.currentSong == songs[0]
-
     midiWrapperMock.simulateInput(nextSongButton)
     assert playerMock.currentSong == songs[1]
 
diff --git a/solo-tool-project/test/solo_tool_integrationtest.py b/solo-tool-project/test/solo_tool_integrationtest.py
index 3d7d20f..e63ea3f 100644
--- a/solo-tool-project/test/solo_tool_integrationtest.py
+++ b/solo-tool-project/test/solo_tool_integrationtest.py
@@ -107,48 +107,7 @@ def test_sanitizePlaybackVolume(uut):
     uut.volume = 150.0
     assert uut.volume == 150.0
 
-def test_addAndSelectSongs(uut, mockPlayer):
-    songs = [
-        "test.mp3",
-        "test.flac"
-    ]
-
-    # Songs are added one by one
-    for song in songs:
-        uut.addSong(song)
-
-    # Songs are not selected automatically
-    assert mockPlayer.currentSong == None
-    assert uut.song == None
-
-    # Song order is preserved
-    assert uut.songs == songs
-
-    # Modifying the song list directly has no effect
-    uut.songs.append("something")
-    assert uut.songs == songs
-
-    # Songs are selected by index
-    for i, s in enumerate(uut.songs):
-        uut.song = i
-        assert mockPlayer.currentSong == uut.songs[i]
-        assert uut.song == i
-
-    # The current song cannot be de-selected
-    uut.song = None
-    assert uut.song == len(uut.songs) - 1
-
-    # Non-existent songs cannot be selected
-    uut.song = -1
-    assert uut.song == len(uut.songs) - 1
-
-    uut.song = 2
-    assert uut.song == len(uut.songs) - 1
-
 def test_addAndJumpToKeyPoints(uut, mockPlayer):
-    uut.addSong("test.flac")
-    uut.addSong("test.mp3")
-
     def checkJump(before, expectedAfter):
         mockPlayer.position = before
         uut.jump()
@@ -160,7 +119,8 @@ def test_addAndJumpToKeyPoints(uut, mockPlayer):
     assert uut.keyPoints is None
     assert uut.keyPoint is None
 
-    uut.song = 0
+    uut.addSong("test.flac")
+    uut.addSong("test.mp3")
 
     # Once a song is selected, jump to start by default
     assert uut.keyPoint == 0.0
@@ -236,12 +196,6 @@ def test_keyPointsPerSong(uut, mockPlayer):
         keyPoints.append(1.0)
         assert 1.0 not in uut.keyPoints
 
-def test_addInexistentSong(uut, mockPlayer):
-    song = "not/a/real/file"
-
-    with pytest.raises(FileNotFoundError):
-        uut.addSong(song)
-
 def test_playingStateNotification(uut, mockPlayer):
     song = "test.flac"
     uut.addSong(song)
@@ -333,43 +287,6 @@ def test_playbackRateNotification(uut, mockPlayer):
     uut.rate = 0.5
     assert not called
 
-def test_currentSongNotification(uut):
-    called = False
-    receivedValue = None
-    def callback(value):
-        nonlocal called, receivedValue
-        called = True
-        receivedValue = value
-
-    uut.registerCurrentSongCallback(callback)
-    assert not called
-
-    songs = [
-        "test.flac",
-        "test.mp3"
-    ]
-
-    # Adding a song does not trigger a notification
-    uut.addSong(songs[0])
-    assert not called
-
-    # Selecting a song for the first time triggers
-    uut.song = 0
-    assert called
-    assert receivedValue == 0
-    called = False
-
-    uut.addSong(songs[1])
-    assert not called
-
-    # Selecting the same song does not trigger
-    uut.song = 0
-    assert not called
-
-    uut.song = 1
-    assert called
-    assert receivedValue == 1
-    called = False
 
 def test_currentKeyPointNotification(uut):
     called = False
-- 
cgit v1.2.3