def test_error_path_bad_arguments(client): with pytest.raises(FoobarRPCError) as error: client.create_playlist("a", "a", "a") assert str( error.value ) == 'Failed unpacking, while expecting type tuple<string,size_t,size_t>' with pytest.raises(FoobarRPCError) as error: client.remove_playlists(["a", "b", "c"]) assert str( error.value) == 'Failed unpacking, while expecting type vector<size_t>' with pytest.raises(FoobarRPCError) as error: client.playlist_reorder_items("a", "b") assert str( error.value ) == 'Failed unpacking, while expecting type tuple<size_t,vector<int>>' with pytest.raises(FoobarRPCError) as error: client.start(99, 99) assert str( error.value) == ('Failed unpacking, while expecting type ' 'tuple<enum t_track_command {track_command_default, ' 'track_command_play, track_command_next, ' 'track_command_prev, track_command_settrack, ' 'track_command_rand},bool>')
def test_playing_playlist_ops(request, client, active_playlist_with_item, new_playlist_with_items): request.addfinalizer(lambda: client.stop()) request.addfinalizer(lambda: client.set_active_playlist(0)) client.start(1, False) time.sleep(0.5) active_playlist = client.get_active_playlist() assert active_playlist == 0 client.set_active_playlist(1) client.set_playing_playlist(1) client.stop() active_playlist = client.get_active_playlist() assert active_playlist == 1 client.play_or_pause() time.sleep(0.5) _, handle = client.get_now_playing() formatted = dict(handle) assert formatted[b'path'] == new_playlist_with_items.files[0].path.encode() client.set_active_playlist(0) client.reset_playing_playlist() assert client.get_playing_playlist() == 0
def test_is_playing(request, client, active_playlist_with_item): assert not client.is_playing() client.start(1, False) request.addfinalizer(lambda: client.stop()) # Foobar needs time for getting the file and starting the actual playback. time.sleep(0.5) assert client.is_playing()
def test_playback_get_length(request, client, active_playlist_with_item): request.addfinalizer(lambda: client.stop()) client.start(1, False) time.sleep(0.5) length = client.playback_get_length() length_ex = client.playback_get_length_ex() assert length == length_ex == active_playlist_with_item.files[0].length
def test_get_playing_item_location(request, client, active_playlist_with_item): client.start(1, False) request.addfinalizer(lambda: client.stop()) time.sleep(0.5) success, playlist, item = client.get_playing_item_location( active_playlist_with_item.index, 0) assert playlist == active_playlist_with_item.index assert item == 0
def test_previous_when_at_first(request, client, active_playlist_with_items): client.start(1, False) request.addfinalizer(lambda: client.stop()) time.sleep(0.5) client.previous() time.sleep(0.5) playing, current_playing = client.get_now_playing() assert not playing assert not current_playing
def test_toggle_pause(request, client, active_playlist_with_item): client.start(1, False) request.addfinalizer(lambda: client.toggle_pause() if client.is_paused() else None) request.addfinalizer(lambda: client.stop()) time.sleep(0.5) assert not client.is_paused() client.toggle_pause() assert client.is_paused() client.toggle_pause() assert not client.is_paused()
def test_play_or_pause(request, client, active_playlist_with_item): client.start(1, False) request.addfinalizer(lambda: client.stop()) time.sleep(0.5) # Now it should be started. assert client.is_playing() client.play_or_pause() assert client.is_paused() client.play_or_pause() assert not client.is_paused() assert client.is_playing()
def test_is_paused(request, client, active_playlist_with_item): # Initially it is not paused assert not client.is_paused() client.start(1, False) request.addfinalizer(lambda: client.stop()) # Foobar needs time for getting the file and starting the actual playback. time.sleep(0.5) client.pause(True) assert client.is_paused() client.pause(False) assert not client.is_paused()
def test_playback_seek_ops(request, client, active_playlist_with_item): request.addfinalizer(lambda: client.stop()) client.start(1, False) time.sleep(0.5) assert client.playback_can_seek() client.playback_seek(2) position = client.playback_get_position() assert position >= 2 client.playback_seek_delta(5) position = client.playback_get_position() assert position >= 7 client.playback_seek_delta(-4) position = client.playback_get_position() assert 3 <= position < 7
def test_get_now_playing(request, client, active_playlist_with_item): client.start(1, False) request.addfinalizer(lambda: client.stop()) # Foobar needs time for getting the file and starting the actual playback. time.sleep(0.5) is_playing, now_playing = client.get_now_playing() assert is_playing now_playing_formatted = dict(now_playing) assert b'index' in now_playing_formatted assert b'path' in now_playing_formatted assert b'selected' in now_playing_formatted assert now_playing_formatted[b'index'] == 0 assert now_playing_formatted[b'path'] == active_playlist_with_item.files[ 0].path.encode() assert now_playing_formatted[b'selected']
def test_previous_next(request, client, active_playlist_with_items): client.start(1, False) request.addfinalizer(lambda: client.stop()) time.sleep(0.5) now_playing = dict(client.get_now_playing()[1]) first = active_playlist_with_items.files[0] second = active_playlist_with_items.files[1] assert now_playing[b'path'] == first.path.encode() client.next() time.sleep(0.5) now_playing = dict(client.get_now_playing()[1]) assert now_playing[b'path'] == second.path.encode() client.previous() time.sleep(0.5) now_playing = dict(client.get_now_playing()[1]) assert now_playing[b'path'] == first.path.encode()