From c75f1ef702b1a3b5cdbbe7f1a87e0f0fbfa80e39 Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Tue, 4 Jan 2022 14:00:01 +0100 Subject: Refactored notifier unit tests --- notifier_unittest.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'notifier_unittest.py') diff --git a/notifier_unittest.py b/notifier_unittest.py index 52be51e..79b2787 100644 --- a/notifier_unittest.py +++ b/notifier_unittest.py @@ -37,17 +37,21 @@ def test_eventWithoutRegisteredCallbacks(uut): uut.notify(Notifier.PLAYING_STATE_EVENT) # expect no crash -def test_playingStateEventWithMockPlayer(uut, mockPlayer): - called = False - def callback(): - nonlocal called - called = True +def test_eventsWithMockPlayer(uut, mockPlayer): + def testEvent(eventCode, simulateEvent): + called = False + def callback(): + nonlocal called + called = True - uut.registerCallback(Notifier.PLAYING_STATE_EVENT, callback) + uut.registerCallback(eventCode, callback) - assert not called - mockPlayer.simulatePlayingStateChanged() - assert called + assert not called + simulateEvent() + assert called + + testEvent(Notifier.PLAYING_STATE_EVENT, mockPlayer.simulatePlayingStateChanged) + #testEvent(Notifier.PLAYBACK_VOLUME_EVENT, mockPlayer.simulatePlaybackVolumeChanged) def test_singleEventNotification(uut): playingStateCalled = False -- cgit v1.2.3