def test_card_leave(): """ The _leave method is called when the card is hidden from the user. Ensure that the sound player is stopped. """ card = Card("title") card.player = mock.MagicMock() card._leave(card) card.player.stop.assert_called_once_with()
def test_card_enter(): """ The _enter method is called when the card is displayed to the user. Ensure that the sound player starts from position zero and the auto advance is scheduled. """ card = Card("title") card.player = mock.MagicMock() card.auto_advance = 1.5 with mock.patch("pypercard.core.Clock") as mock_clock: card._enter(card) mock_clock.schedule_once.assert_called_once_with( card._next_card, card.auto_advance) card.player.play.assert_called_once_with() card.player.seek.assert_called_once_with(0)