aboutsummaryrefslogtreecommitdiffstats
path: root/session_manager_unittest.py
diff options
context:
space:
mode:
authorEddy Pedroni <eddy@0xf7.com>2021-12-22 22:14:43 +0100
committerEddy Pedroni <eddy@0xf7.com>2021-12-22 22:14:43 +0100
commit71593d438dff1a54986c94b469faa31c4581f6c7 (patch)
treed9209575ef368d015728937b47c5601ed3268bec /session_manager_unittest.py
parent5f7e75ae1e53d3833114880d20e899629d21e31a (diff)
Fixed additive loading issue
Diffstat (limited to 'session_manager_unittest.py')
-rw-r--r--session_manager_unittest.py23
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))