mpd: Update playlistdelete to handle unknown names and indexes
This commit is contained in:
parent
b21debf6ee
commit
5de9495eaa
@ -254,9 +254,12 @@ def playlistdelete(context, name, songpos):
|
|||||||
if not playlist:
|
if not playlist:
|
||||||
raise exceptions.MpdNoExistError('No such playlist')
|
raise exceptions.MpdNoExistError('No such playlist')
|
||||||
|
|
||||||
# Convert tracks to list and remove requested
|
try:
|
||||||
tracks = list(playlist.tracks)
|
# Convert tracks to list and remove requested
|
||||||
tracks.pop(songpos)
|
tracks = list(playlist.tracks)
|
||||||
|
tracks.pop(songpos)
|
||||||
|
except IndexError:
|
||||||
|
raise exceptions.MpdArgError('Bad song index')
|
||||||
|
|
||||||
# Replace tracks and save playlist
|
# Replace tracks and save playlist
|
||||||
playlist = playlist.replace(tracks=tracks)
|
playlist = playlist.replace(tracks=tracks)
|
||||||
|
|||||||
@ -314,6 +314,15 @@ class PlaylistsHandlerTest(protocol.BaseTestCase):
|
|||||||
'invalid: playlist names may not contain '
|
'invalid: playlist names may not contain '
|
||||||
'slashes, newlines or carriage returns')
|
'slashes, newlines or carriage returns')
|
||||||
|
|
||||||
|
def test_playlistdelete_unknown_playlist_acks(self):
|
||||||
|
self.send_request('playlistdelete "foobar" "0"')
|
||||||
|
self.assertInResponse('ACK [50@0] {playlistdelete} No such playlist')
|
||||||
|
|
||||||
|
def test_playlistdelete_unknown_index_acks(self):
|
||||||
|
self.send_request('save "foobar"')
|
||||||
|
self.send_request('playlistdelete "foobar" "0"')
|
||||||
|
self.assertInResponse('ACK [2@0] {playlistdelete} Bad song index')
|
||||||
|
|
||||||
def test_playlistmove(self):
|
def test_playlistmove(self):
|
||||||
tracks = [
|
tracks = [
|
||||||
Track(uri='dummy:a'),
|
Track(uri='dummy:a'),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user