async def test_playlist_change_mode(app_mock, mocker): # from normal to fm pl = Playlist(app_mock) pl.mode = PlaylistMode.fm assert pl.playback_mode is PlaybackMode.sequential # from fm to normal pl.mode = PlaylistMode.normal assert pl.mode is PlaylistMode.normal
async def test_playlist_change_mode(app_mock, mocker): mock_clear = mocker.patch.object(Playlist, 'clear') # from normal to fm pl = Playlist(app_mock) pl.mode = PlaylistMode.fm mock_clear.assert_called_once_with() assert pl.playback_mode is PlaybackMode.sequential # from fm to normal pl.mode = PlaylistMode.normal assert pl.mode is PlaylistMode.normal
async def test_playlist_exit_fm_mode(app_mock, song, mocker): mocker.patch.object(Playlist, 'a_set_current_song') pl = Playlist(app_mock) pl.mode = PlaylistMode.fm pl.current_song = song assert pl.mode is PlaylistMode.normal assert app_mock.task_mgr.get_or_create.called
async def test_playlist_exit_fm_mode(app_mock, song, mocker, mock_a_set_cursong): pl = Playlist(app_mock) pl.mode = PlaylistMode.fm pl.current_song = song assert pl.mode is PlaylistMode.normal assert app_mock.task_mgr.get_or_create.called
def test_play_all(app_mock): player = Player() playlist = Playlist(app_mock) player.set_playlist(playlist) playlist.mode = PlaylistMode.fm playlist.set_models([], next_=True) assert playlist.mode == PlaylistMode.normal
async def test_playlist_fm_mode_play_previous(app_mock, song, song1, mocker): pl = Playlist(app_mock) pl.mode = PlaylistMode.fm pl.fm_add(song1) pl.fm_add(song) pl._current_song = song pl.current_song = song1 # should not exit fm mode assert pl.mode is PlaylistMode.fm
async def test_playlist_fm_mode_play_next(app_mock, song, song1, mocker): mocker.patch.object(Playlist, 'a_set_current_song') pl = Playlist(app_mock) pl.mode = PlaylistMode.fm pl.fm_add(song1) pl.fm_add(song) pl._current_song = song1 pl.current_song = song # should not exit fm mode assert pl.mode is PlaylistMode.fm
async def test_playlist_fm_mode_play_next(app_mock, song, song1, mock_a_set_cursong): pl = Playlist(app_mock) pl.mode = PlaylistMode.fm pl.fm_add(song1) pl.fm_add(song) pl._current_song = song1 pl.current_song = song # should not exit fm mode assert pl.mode is PlaylistMode.fm
async def test_playlist_eof_reached(app_mock, song, mocker): mock_emit = mocker.patch.object(Signal, 'emit') pl = Playlist(app_mock) pl.mode = PlaylistMode.fm pl.next() # first emit pl.fm_add(song) # assume current_song is song pl._current_song = song pl.next() # second emit mock_emit.assert_has_calls([ mock.call(), mock.call(), ])
async def test_playlist_resumed_from_eof_reached(app_mock, song, mocker, mock_a_set_cursong): mock_set_current_song = mocker.patch.object(Playlist, 'set_current_song') pl = Playlist(app_mock) def feed_playlist(): pl.fm_add(song) pl.next() pl.eof_reached.connect(feed_playlist) pl.mode = PlaylistMode.fm pl.next() mock_set_current_song.assert_has_calls([mock.call(song)])
async def test_playlist_resumed_from_eof_reached(app_mock, song, mocker): mock_current_song = mocker.patch.object(Playlist, 'current_song') mock_set = mocker.MagicMock() mock_current_song.__get__ = mocker.MagicMock(return_value=None) mock_current_song.__set__ = mock_set pl = Playlist(app_mock) def feed_playlist(): pl.fm_add(song) pl.next() pl.eof_reached.connect(feed_playlist) pl.mode = PlaylistMode.fm pl.next() mock_set.assert_has_calls([mock.call(pl, song)])
async def test_playlist_eof_reached(app_mock, song, mocker, mock_a_set_cursong): mock_emit = mocker.patch.object(Signal, 'emit') pl = Playlist(app_mock) pl.mode = PlaylistMode.fm pl.next() # first emit pl.fm_add(song) # assume current_song is song pl._current_song = song pl.next() # second emit mock_emit.assert_has_calls([ mock.call(PlaybackMode.sequential), mock.call(PlaylistMode.fm), mock.call(), mock.call(0, 1), # songs_added mock.call() ])