From 10aa8140b5e52cc0cf8cea794daf81fb0ffdcad3 Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Sat, 25 Dec 2021 23:47:00 +0100 Subject: Renamed some functions, added known issue --- abcontroller.py | 4 ++-- abcontroller_unittest.py | 50 +++++++++++++++++++++++++------------------- known-issues | 1 + session_manager.py | 6 +++--- session_manager_unittest.py | 6 +++--- solo_tool.py | 6 +++--- solo_tool_integrationtest.py | 14 ++++++------- solo_tool_qt.py | 2 +- 8 files changed, 48 insertions(+), 41 deletions(-) diff --git a/abcontroller.py b/abcontroller.py index 2e08936..80f6a4d 100644 --- a/abcontroller.py +++ b/abcontroller.py @@ -19,7 +19,7 @@ class ABController: self._songLimits = self._limits[path] self._currentLimits = None - def addLimits(self, aLimit, bLimit, song=None): + def storeLimits(self, aLimit, bLimit, song=None): if song is not None: self._ensureSongExists(song) songLimits = self._limits[song] @@ -32,7 +32,7 @@ class ABController: ab = _AB(aLimit, bLimit) songLimits.append(ab) - def setCurrentLimits(self, index): + def loadLimits(self, index): if not self._songLimits: return diff --git a/abcontroller_unittest.py b/abcontroller_unittest.py index 8eb401a..0e004ff 100644 --- a/abcontroller_unittest.py +++ b/abcontroller_unittest.py @@ -33,8 +33,8 @@ def test_oneSetOfLimits(): uut = ABController() uut.setCurrentSong(song) - uut.addLimits(abLimits.a, abLimits.b) - uut.setCurrentLimits(0) + uut.storeLimits(abLimits.a, abLimits.b) + uut.loadLimits(0) checkLimits(uut, abLimits.a, abLimits.b) assert uut.getLimits(song) == [abLimits] @@ -50,10 +50,10 @@ def test_multipleSetsOfLimits(): uut = ABController() uut.setCurrentSong(song) for l in abLimits: - uut.addLimits(l.a, l.b) + uut.storeLimits(l.a, l.b) for i, l in enumerate(abLimits): - uut.setCurrentLimits(i) + uut.loadLimits(i) checkLimits(uut, l.a, l.b) assert uut.getLimits(song) == abLimits @@ -69,11 +69,11 @@ def test_multipleSongs(): ] uut = ABController() for i, s in enumerate(songs): - uut.addLimits(abLimits[i].a, abLimits[i].b, s) + uut.storeLimits(abLimits[i].a, abLimits[i].b, s) for i, s in enumerate(songs): uut.setCurrentSong(s) - uut.setCurrentLimits(0) + uut.loadLimits(0) checkLimits(uut, abLimits[i].a, abLimits[i].b) assert uut.getLimits(s) == [abLimits[i]] @@ -83,8 +83,8 @@ def test_disableAbRepeat(): uut = ABController() uut.setCurrentSong(song) - uut.addLimits(abLimits.a, abLimits.b) - uut.setCurrentLimits(0) + uut.storeLimits(abLimits.a, abLimits.b) + uut.loadLimits(0) uut.setEnable(False) checkLimits(uut, abLimits.a, abLimits.b, fail=True) @@ -92,28 +92,28 @@ def test_disableAbRepeat(): uut.setEnable(True) checkLimits(uut, abLimits.a, abLimits.b) -def test_addLimitsToSpecificSong(): +def test_storeLimitsToSpecificSong(): song = "/path/to/song" uut = ABController() - uut.addLimits(abLimits.a, abLimits.b, song) + uut.storeLimits(abLimits.a, abLimits.b, song) uut.setCurrentSong(song) - uut.setCurrentLimits(0) + uut.loadLimits(0) checkLimits(uut, abLimits.a, abLimits.b) -def test_addLimitsWithoutCurrentSong(): +def test_storeLimitsWithoutCurrentSong(): uut = ABController() - uut.addLimits(abLimits.a, abLimits.b) - uut.setCurrentLimits(0) + uut.storeLimits(abLimits.a, abLimits.b) + uut.loadLimits(0) checkLimits(uut, abLimits.a, abLimits.b, fail=True) -def test_addLimitsToSongWithoutCurrentSong(): +def test_storeLimitsToSongWithoutCurrentSong(): song = "/path/to/song" uut = ABController() - uut.addLimits(abLimits.a, abLimits.b, song) - uut.setCurrentLimits(0) + uut.storeLimits(abLimits.a, abLimits.b, song) + uut.loadLimits(0) checkLimits(uut, abLimits.a, abLimits.b, fail=True) @@ -121,19 +121,19 @@ def test_addLimitsToSongWithoutCurrentSong(): checkLimits(uut, abLimits.a, abLimits.b, fail=True) - uut.setCurrentLimits(0) + uut.loadLimits(0) checkLimits(uut, abLimits.a, abLimits.b) -def test_addLimitsToCurrentSongButDoNotSetCurrentLimits(): +def test_storeLimitsToCurrentSongButDoNotSetCurrentLimits(): song = "/path/to/song" uut = ABController() uut.setCurrentSong(song) - uut.addLimits(abLimits.a, abLimits.b) + uut.storeLimits(abLimits.a, abLimits.b) checkLimits(uut, abLimits.a, abLimits.b, fail=True) - uut.setCurrentLimits(0) + uut.loadLimits(0) checkLimits(uut, abLimits.a, abLimits.b) @@ -150,7 +150,7 @@ def test_clearAbController(): uut = ABController() for s in songsWithLimits: - uut.addLimits(s[1].a, s[1].b, s[0]) + uut.storeLimits(s[1].a, s[1].b, s[0]) for i, s in enumerate(songsWithLimits): assert uut.getLimits(s[0]) == [s[1]] @@ -160,3 +160,9 @@ def test_clearAbController(): for i, s in enumerate(songsWithLimits): assert uut.getLimits(s[0]) == None +def test_setTemporaryLimits(): + pass + +def test_defaultBehaviour(): + uut = ABController() + diff --git a/known-issues b/known-issues index 2b63f65..ee52956 100644 --- a/known-issues +++ b/known-issues @@ -2,3 +2,4 @@ * (done) Loading session is additive, should clear the state first * AB limits are displayed as p.u., should be timestamps * (done) Songs are displayed as full path, should be file name or ideally title from metadata +* When switching between songs, AB limit selection is not reset, this means that if the song has only one limit, it is not possible ot load it anymore diff --git a/session_manager.py b/session_manager.py index fd6b4ad..640188d 100644 --- a/session_manager.py +++ b/session_manager.py @@ -8,8 +8,8 @@ class SessionManager: def addSong(self, path): self._playlist.addSong(path) - def addLimits(self, aLimit, bLimit): - self._abController.addLimits(aLimit, bLimit) + def storeLimits(self, aLimit, bLimit): + self._abController.storeLimits(aLimit, bLimit) def loadSession(self, file): jsonStr = file.read() @@ -25,7 +25,7 @@ class SessionManager: if abLimits is not None: for l in abLimits: - self._abController.addLimits(l[0], l[1], songPath) + self._abController.storeLimits(l[0], l[1], songPath) def saveSession(self, file): songs = self._playlist.getSongs() diff --git a/session_manager_unittest.py b/session_manager_unittest.py index 532ae75..30283a1 100644 --- a/session_manager_unittest.py +++ b/session_manager_unittest.py @@ -40,7 +40,7 @@ class ABControllerMock: def __init__(self): self.limits = dict() - def addLimits(self, aLimit, bLimit, song="current"): + def storeLimits(self, aLimit, bLimit, song="current"): if song not in self.limits: self.limits[song] = list() self.limits[song].append([aLimit, bLimit]) @@ -88,7 +88,7 @@ def test_addAbLimits(): uut = SessionManager(None, abControllerMock) for i, ab in enumerate(abLimits): - uut.addLimits(ab[0], ab[1]) + uut.storeLimits(ab[0], ab[1]) assert abControllerMock.limits["current"][i] == ab def test_loadSession(): @@ -120,7 +120,7 @@ def test_saveSession(): abLimits = entry["ab_limits"] if abLimits is not None: for l in abLimits: - abControllerMock.addLimits(l[0], l[1], song) + abControllerMock.storeLimits(l[0], l[1], song) sessionFile = MockFile() uut.saveSession(sessionFile) diff --git a/solo_tool.py b/solo_tool.py index 79913a4..8530125 100644 --- a/solo_tool.py +++ b/solo_tool.py @@ -33,11 +33,11 @@ class SoloTool: def getSongs(self): return self._playlist.getSongs() - def addAbLimit(self, aLimit, bLimit): - self._abController.addLimits(aLimit, bLimit) + def storeAbLimits(self, aLimit, bLimit): + self._abController.storeLimits(aLimit, bLimit) def setAbLimit(self, index): - self._abController.setCurrentLimits(index) + self._abController.loadLimits(index) def getAbLimits(self): currentSong = self._playlist.getCurrentSong() diff --git a/solo_tool_integrationtest.py b/solo_tool_integrationtest.py index 22e8143..2a2bd46 100644 --- a/solo_tool_integrationtest.py +++ b/solo_tool_integrationtest.py @@ -96,8 +96,8 @@ def test_addAndSetAbLimits(): uut.addSong(song) uut.setSong(0) - uut.addAbLimit(abLimits[0][0], abLimits[0][1]) - uut.addAbLimit(abLimits[1][0], abLimits[1][1]) + uut.storeAbLimits(abLimits[0][0], abLimits[0][1]) + uut.storeAbLimits(abLimits[1][0], abLimits[1][1]) mockPlayer.position = 0.0 uut.tick() @@ -145,7 +145,7 @@ def test_multipleSongsAndAbLimits(): for i, l in enumerate(abLimits): uut.setSong(i) - uut.addAbLimit(l[0], l[1]) + uut.storeAbLimits(l[0], l[1]) uut.setAbLimitEnable(True) @@ -161,7 +161,7 @@ def test_multipleSongsAndAbLimits(): uut.tick() assert mockPlayer.position == l[0] -def test_addAbLimitWithoutSong(): +def test_storeAbLimitsWithoutSong(): song = "test.flac" abLimit = [0.2, 0.4] overflow = abLimit[1] + 0.1 @@ -170,7 +170,7 @@ def test_addAbLimitWithoutSong(): mockPlayer.position = overflow uut.setAbLimitEnable(True) - uut.addAbLimit(abLimit[0], abLimit[1]) + uut.storeAbLimits(abLimit[0], abLimit[1]) uut.tick() assert mockPlayer.position == overflow @@ -194,7 +194,7 @@ def test_addAbLimitWithoutSong(): uut.tick() assert mockPlayer.position == overflow - uut.addAbLimit(abLimit[0], abLimit[1]) + uut.storeAbLimits(abLimit[0], abLimit[1]) uut.tick() assert mockPlayer.position == overflow @@ -250,7 +250,7 @@ def test_getters(): uut.addSong(song) uut.setSong(0) - uut.addAbLimit(abLimit[0], abLimit[1]) + uut.storeAbLimits(abLimit[0], abLimit[1]) assert uut.getSongs() == [song] diff --git a/solo_tool_qt.py b/solo_tool_qt.py index 9f4b7aa..7c17a33 100644 --- a/solo_tool_qt.py +++ b/solo_tool_qt.py @@ -87,7 +87,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): def saveAbLimits(self): a = self.aSlider.value() / float(POSITION_FACTOR) b = self.bSlider.value() / float(POSITION_FACTOR) - self.soloTool.addAbLimit(a, b) + self.soloTool.storeAbLimits(a, b) self.abListModel.layoutChanged.emit() def toggleAbRepeat(self): -- cgit v1.2.3