From 6b23d5fef7ab1a936e133d620bd277274882b3a7 Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Mon, 3 Jan 2022 20:29:51 +0100 Subject: Added playing state callback to player, refactored notifier to use it --- notifier_unittest.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'notifier_unittest.py') 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 -- cgit v1.2.3