aboutsummaryrefslogtreecommitdiffstats
path: root/notifier_unittest.py
diff options
context:
space:
mode:
Diffstat (limited to 'notifier_unittest.py')
-rw-r--r--notifier_unittest.py36
1 files changed, 19 insertions, 17 deletions
diff --git a/notifier_unittest.py b/notifier_unittest.py
index 9f37992..13f2285 100644
--- a/notifier_unittest.py
+++ b/notifier_unittest.py
@@ -11,34 +11,36 @@ def mockPlayer():
def uut(mockPlayer):
return Notifier(mockPlayer)
-def checkEvent(uut, event):
- callbacks = 2
- calledFlags = [False] * 2
+def test_allEvents(uut):
+ def checkEvent(uut, event):
+ callbacks = 2
+ calledFlags = [False] * 2
- def createCallback(i):
- def cb():
- nonlocal calledFlags
- calledFlags[i] = True
- return cb
+ def createCallback(i):
+ def cb():
+ nonlocal calledFlags
+ calledFlags[i] = True
+ return cb
- for i in range(0, callbacks):
- uut.registerCallback(event, createCallback(i))
+ for i in range(0, callbacks):
+ uut.registerCallback(event, createCallback(i))
- assert not any(calledFlags)
- uut.notify(event)
- assert all(calledFlags)
+ assert not any(calledFlags)
+ uut.notify(event)
+ assert all(calledFlags)
-def test_allEvents(uut):
checkEvent(uut, Notifier.PLAYING_STATE_EVENT)
checkEvent(uut, Notifier.PLAYBACK_VOLUME_EVENT)
checkEvent(uut, Notifier.PLAYBACK_RATE_EVENT)
+ checkEvent(uut, Notifier.CURRENT_SONG_EVENT)
+ checkEvent(uut, Notifier.CURRENT_AB_EVENT)
def test_eventWithoutRegisteredCallbacks(uut):
uut.notify(Notifier.PLAYING_STATE_EVENT)
# expect no crash
def test_eventsWithMockPlayer(uut, mockPlayer):
- def testEvent(eventCode, simulateEvent):
+ def checkEvent(eventCode, simulateEvent):
called = False
def callback():
nonlocal called
@@ -50,8 +52,8 @@ def test_eventsWithMockPlayer(uut, mockPlayer):
simulateEvent()
assert called
- testEvent(Notifier.PLAYING_STATE_EVENT, mockPlayer.simulatePlayingStateChanged)
- testEvent(Notifier.PLAYBACK_VOLUME_EVENT, mockPlayer.simulatePlaybackVolumeChanged)
+ checkEvent(Notifier.PLAYING_STATE_EVENT, mockPlayer.simulatePlayingStateChanged)
+ checkEvent(Notifier.PLAYBACK_VOLUME_EVENT, mockPlayer.simulatePlaybackVolumeChanged)
def test_singleEventNotification(uut):
playingStateCalled = False