diff options
Diffstat (limited to 'session_manager_unittest.py')
-rw-r--r-- | session_manager_unittest.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/session_manager_unittest.py b/session_manager_unittest.py index 7fb8c55..532ae75 100644 --- a/session_manager_unittest.py +++ b/session_manager_unittest.py @@ -33,6 +33,9 @@ class PlaylistMock: def getSongs(self): return self.songs + def clear(self): + self.__init__() + class ABControllerMock: def __init__(self): self.limits = dict() @@ -45,6 +48,9 @@ class ABControllerMock: def getLimits(self, song): return self.limits.get(song) + def clear(self): + self.__init__() + class MockFile: def __init__(self, init=""): self.contents = init @@ -138,3 +144,20 @@ def test_loadAndSaveEmptySession(): assert songs == list() for s in songs: assert abControllerMock.getLimits(s) == None + +def test_loadSessionNotAdditive(): + playlistMock = PlaylistMock() + abControllerMock = ABControllerMock() + uut = SessionManager(playlistMock, abControllerMock) + + sessionFile = MockFile(dumps(testSession)) + uut.loadSession(sessionFile) + uut.loadSession(sessionFile) + + songs = playlistMock.getSongs() + assert len(songs) == len(set(songs)) + for s in songs: + abLimits = abControllerMock.getLimits(s) + if abLimits is not None: + abLimitStr = [f"[{l[0]}, {l[1]}] " for l in abLimits] + assert len(abLimitStr) == len(set(abLimitStr)) |