diff options
Diffstat (limited to 'notifier_unittest.py')
-rw-r--r-- | notifier_unittest.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/notifier_unittest.py b/notifier_unittest.py index 721a5fd..b840c16 100644 --- a/notifier_unittest.py +++ b/notifier_unittest.py @@ -1,10 +1,15 @@ import pytest from notifier import Notifier +from player_mock import Player @pytest.fixture -def uut(): - return Notifier() +def mockPlayer(): + return Player() + +@pytest.fixture +def uut(mockPlayer): + return Notifier(mockPlayer) def checkEvent(uut, event): callbacks = 2 @@ -29,4 +34,15 @@ def test_allEvents(uut): 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 + + uut.registerCallback(Notifier.PLAYING_STATE_EVENT, callback) + + assert not called + mockPlayer.simulatePlayingStateChanged() + assert called |