aboutsummaryrefslogtreecommitdiffstats
path: root/notifier_unittest.py
diff options
context:
space:
mode:
authorEddy Pedroni <eddy@0xf7.com>2022-01-03 20:29:51 +0100
committerEddy Pedroni <eddy@0xf7.com>2022-01-03 20:29:51 +0100
commit6b23d5fef7ab1a936e133d620bd277274882b3a7 (patch)
tree063abde114b678bbf64dbe042ef50483c7a2a164 /notifier_unittest.py
parentbfa2abe556269de927e399a0547b18126a78ff96 (diff)
Added playing state callback to player, refactored notifier to use it
Diffstat (limited to 'notifier_unittest.py')
-rw-r--r--notifier_unittest.py22
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