aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEddy Pedroni <eddy@0xf7.com>2021-12-21 20:26:05 +0100
committerEddy Pedroni <eddy@0xf7.com>2021-12-21 20:26:05 +0100
commit663970d0165e226147d95fb92c617714dfbd7553 (patch)
treee65c2dd0ffdd89ab06b9300d3d5f3428916d1870
parentae8f0a04190c3d13292ad68548f5275507e5812e (diff)
Rolled back some refactorings, added some integration tests
-rw-r--r--diagram.drawio2
-rw-r--r--playlist.py4
-rw-r--r--playlist_unittest.py53
-rw-r--r--solo_tool.py5
-rw-r--r--solo_tool_integrationtest.py9
5 files changed, 47 insertions, 26 deletions
diff --git a/diagram.drawio b/diagram.drawio
index 3fc9e3f..2600d4c 100644
--- a/diagram.drawio
+++ b/diagram.drawio
@@ -1 +1 @@
-<mxfile host="app.diagrams.net" modified="2021-12-21T17:41:54.343Z" agent="5.0 (X11)" etag="0TS7O8wDBKDC3BJ4ppdc" version="16.0.0" type="device"><diagram id="g-wcGVps3MkI6_XAwNEs" name="Page-1">7Vxbd9o4EP41PJJjW74+BpI22ZNsu0svSd8EFsYbY1FbkKS/fmUs44uEa8AXvOwTlizJ0sx8M6PRiAEYL98+BnC1eMQ28gaKZL8NwM1AUWRVkehPVPPOagzZimucwLVZXVoxcX8hVsk6OmvXRmGuIcHYI+4qXznDvo9mJFcHgwC/5pvNsZf/6go6iKuYzKDH1353bbJgtbJupS/ukOss2KdNxYhfLGHSmK0kXEAbv2aqwO0AjAOMSfy0fBsjL6JeQpe434c9b3cTC5BPqnTQ7kfyF3RzbQZ/Od/wRnG9559DNsoGemu2YDZZ8p5QIMBr30bRINIAjF4XLkGTFZxFb18p02ndgiw9WpLpow3DxbZtVHA8GIas327128ILIrMFK8xdzxtjDwe07GOfjjtik0IBQW97VyvvaEilD+ElIsE7bcI6aBojeyJ4KmPYa8pFDbA2iwwDd5WQSY6zGzslLn1g9BXT+vGr/DyZjr7cGuDlu+b41s/ht6HGkRbZVNZYEQdkgR3sQ+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3v/vlp4z19tO9+nFP2T1Wz08BeqfKJcg+yf2Tez4t2SZ4b8s7d+VubYlJG99amG0ete2sjC7ywM9zk8F5XvMuJsxQuY3OjFSLUggC10WZcwLxUyGgVLYjcrcXgcz/GC4yjA9GLgo1aTADkYWO1GRKQO8ZNa46WwcOkB/t7mU/6iIPSG+ytlxeUTaDnYaMLXLSmQmniMLTE0f4y7I2iVLQ3nUYEklmKzM2xsehexwTM33prstQQfoS3XtRO4MNiAslzxuh0ExMos0BZgJVdHGo6ydySpCsgp2nlIO+/FO+MxdOuI8lcuGhRCnHt947OMZ+8DEW15JObgHH2RHkZKiDfpZZ8cuHyK11CO+7CQT+vovVHSFQ9p0aGctHSNCc1fPSGuMtTj8lqsNFm4dCr1bthQie344SlY6+CKYfeBTvUMd4fkjynOIxwlvyljpLQZWs6rLJuyrNmv9CW6TAL5F2YejRasuPY3apqQJ0J19vx6ZpxVFZHC7vXk0Da1uZVOMlKbo0wr+rcfZU6ca5V9lUSSCr1uC6ggPQmrk+WCW+5XIQoDEu2MvxFe+hDJ71hf7DstHK8e9L/oegFv0o2u/arZL1PjlWN6lcW3ITt9Hy3dJYZoD1guPWSEnBVDhp2fVh12j8JmVpBg7Z3WiXmTCeJEXUCYI/VOtEmGcYeFVd/VK5kWfljKrhB/yNm2Nz5Li2m/6AWMzL9Izpw+y8=</diagram></mxfile> \ No newline at end of file
+<mxfile host="app.diagrams.net" modified="2021-12-21T19:25:27.462Z" agent="5.0 (X11)" etag="_IciWg4MnHRTNr6CcxUi" version="16.0.0" type="device"><diagram id="g-wcGVps3MkI6_XAwNEs" name="Page-1">7Vxde6I4FP41XtoHCJ+X1XZmuk9nZ3adj3buokRki6QD0bbz6zdIIh+JDCqCLnslCUlIcs77npOTxAEYL1/fR/B58RG7KBhoivs6ADcDTVN1TaE/Sc4by7FUJ83xIt9leVnGxP+FWCar6K18F8WFggTjgPjPxcwZDkM0I4U8GEX4pVhsjoPiV5+hh4SMyQwGYu533yULlquaTvbiA/K9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ff --git a/playlist.py b/playlist.py
index e5a4daf..5c52774 100644
--- a/playlist.py
+++ b/playlist.py
@@ -1,10 +1,10 @@
import logging
class Playlist:
- def __init__(self, player):
+ def __init__(self, callback):
self._songList = list()
self._currentSong = None
- self._setSongCallback = player.setCurrentSong
+ self._setSongCallback = callback
def addSong(self, path):
self._songList.append(path)
diff --git a/playlist_unittest.py b/playlist_unittest.py
index 06785cc..ff5a79c 100644
--- a/playlist_unittest.py
+++ b/playlist_unittest.py
@@ -1,67 +1,76 @@
from playlist import Playlist
-class MockPlayer:
- def __init__(self):
- self.songSetByCallback = None
-
- def setCurrentSong(self, path):
- self.songSetByCallback = path
-
def test_addAndSelectOneSong():
songAddedByUser = "/path/to/song"
- mockPlayer = MockPlayer()
+ songSetByCallback = None
+
+ def testCallback(song):
+ nonlocal songSetByCallback
+ songSetByCallback = song
- uut = Playlist(mockPlayer)
+ uut = Playlist(testCallback)
uut.addSong(songAddedByUser)
uut.setCurrentSong(0)
- assert songAddedByUser == mockPlayer.songSetByCallback
+ assert songAddedByUser == songSetByCallback
assert uut.getCurrentSong() == songAddedByUser
assert uut.getSongs() == [songAddedByUser]
def test_addTwoSongsAndSelectBoth():
songAddedByUser = ["/path/to/song", "/path/to/second/song"]
- mockPlayer = MockPlayer()
+ songSetByCallback = None
- uut = Playlist(mockPlayer)
+ def testCallback(song):
+ nonlocal songSetByCallback
+ songSetByCallback = song
+
+ uut = Playlist(testCallback)
uut.addSong(songAddedByUser[0])
uut.addSong(songAddedByUser[1])
assert uut.getSongs() == songAddedByUser
uut.setCurrentSong(0)
- assert songAddedByUser[0] == mockPlayer.songSetByCallback
+ assert songAddedByUser[0] == songSetByCallback
assert uut.getCurrentSong() == songAddedByUser[0]
uut.setCurrentSong(1)
- assert songAddedByUser[1] == mockPlayer.songSetByCallback
+ assert songAddedByUser[1] == songSetByCallback
assert uut.getCurrentSong() == songAddedByUser[1]
def test_firstAddedSongIsNotSelected():
songAddedByUser = "/path/to/song"
- mockPlayer = MockPlayer()
+ songSetByCallback = None
+
+ def testCallback(song):
+ nonlocal songSetByCallback
+ songSetByCallback = song
- uut = Playlist(mockPlayer)
+ uut = Playlist(testCallback)
uut.addSong(songAddedByUser)
- assert mockPlayer.songSetByCallback == None
+ assert songSetByCallback == None
assert uut.getCurrentSong() == None
assert uut.getSongs() == [songAddedByUser]
def test_invalidSongSelection():
songAddedByUser = "/path/to/song"
- mockPlayer = MockPlayer()
+ songSetByCallback = None
+
+ def testCallback(song):
+ nonlocal songSetByCallback
+ songSetByCallback = song
- uut = Playlist(mockPlayer)
- assert mockPlayer.songSetByCallback == None
+ uut = Playlist(testCallback)
+ assert songSetByCallback == None
assert uut.getCurrentSong() == None
uut.setCurrentSong(10)
- assert mockPlayer.songSetByCallback == None
+ assert songSetByCallback == None
assert uut.getCurrentSong() == None
uut.addSong(songAddedByUser)
uut.setCurrentSong(10)
- assert mockPlayer.songSetByCallback == None
+ assert songSetByCallback == None
assert uut.getCurrentSong() == None
assert uut.getSongs() == [songAddedByUser]
diff --git a/solo_tool.py b/solo_tool.py
index da1a402..b1edba6 100644
--- a/solo_tool.py
+++ b/solo_tool.py
@@ -6,10 +6,13 @@ from player_vlc import Player
class SoloTool:
def __init__(self, player=None):
self._player = Player() if player is None else player
- self._playlist = Playlist(self._player)
+ self._playlist = Playlist(self._playlistCallback)
self._abController = ABController()
self._sessionManager = SessionManager(self._playlist, self._abController)
+ def _playlistCallback(self, path):
+ self._player.setCurrentSong("")
+
def addSong(self, path):
self._sessionManager.addSong(path)
diff --git a/solo_tool_integrationtest.py b/solo_tool_integrationtest.py
index 19bb406..561778b 100644
--- a/solo_tool_integrationtest.py
+++ b/solo_tool_integrationtest.py
@@ -43,6 +43,15 @@ class MockPlayer():
def setCurrentSong(self, path):
self.currentSong = path
+def test_addAndSetSong():
+ song = "/path/to/song"
+ mockPlayer = MockPlayer()
+
+ uut = SoloTool(mockPlayer)
+
+ uut.addSong(song)
+ uut.setSong(0)
+
def test_playerControls():
mockPlayer = MockPlayer()
uut = SoloTool(mockPlayer)