MPD: Support listplaylist{,info} without quotes around spaceless playlist name (fixes #218)

This commit is contained in:
Stein Magnus Jodal 2012-11-01 22:27:53 +01:00
parent 548dd186cf
commit 60112897d2
3 changed files with 25 additions and 0 deletions

View File

@ -70,6 +70,11 @@ backends:
- Added support for search by filename to local backend. - Added support for search by filename to local backend.
**Bug fixes**
- :issue:`218`: The MPD commands ``listplaylist`` and ``listplaylistinfo`` now
accepts unquotes playlist names if they don't contain spaces.
v0.8.1 (2012-10-30) v0.8.1 (2012-10-30)
=================== ===================

View File

@ -5,6 +5,7 @@ from mopidy.frontends.mpd.protocol import handle_request
from mopidy.frontends.mpd.translator import playlist_to_mpd_format from mopidy.frontends.mpd.translator import playlist_to_mpd_format
@handle_request(r'^listplaylist (?P<name>\S+)$')
@handle_request(r'^listplaylist "(?P<name>[^"]+)"$') @handle_request(r'^listplaylist "(?P<name>[^"]+)"$')
def listplaylist(context, name): def listplaylist(context, name):
""" """
@ -27,6 +28,7 @@ def listplaylist(context, name):
raise MpdNoExistError(u'No such playlist', command=u'listplaylist') raise MpdNoExistError(u'No such playlist', command=u'listplaylist')
@handle_request(r'^listplaylistinfo (?P<name>\S+)$')
@handle_request(r'^listplaylistinfo "(?P<name>[^"]+)"$') @handle_request(r'^listplaylistinfo "(?P<name>[^"]+)"$')
def listplaylistinfo(context, name): def listplaylistinfo(context, name):
""" """

View File

@ -14,6 +14,14 @@ class StoredPlaylistsHandlerTest(protocol.BaseTestCase):
self.assertInResponse(u'file: file:///dev/urandom') self.assertInResponse(u'file: file:///dev/urandom')
self.assertInResponse(u'OK') self.assertInResponse(u'OK')
def test_listplaylist_without_quotes(self):
self.core.stored_playlists.playlists = [
Playlist(name='name', tracks=[Track(uri='file:///dev/urandom')])]
self.sendRequest(u'listplaylist name')
self.assertInResponse(u'file: file:///dev/urandom')
self.assertInResponse(u'OK')
def test_listplaylist_fails_if_no_playlist_is_found(self): def test_listplaylist_fails_if_no_playlist_is_found(self):
self.sendRequest(u'listplaylist "name"') self.sendRequest(u'listplaylist "name"')
self.assertEqualResponse(u'ACK [50@0] {listplaylist} No such playlist') self.assertEqualResponse(u'ACK [50@0] {listplaylist} No such playlist')
@ -28,6 +36,16 @@ class StoredPlaylistsHandlerTest(protocol.BaseTestCase):
self.assertNotInResponse(u'Pos: 0') self.assertNotInResponse(u'Pos: 0')
self.assertInResponse(u'OK') self.assertInResponse(u'OK')
def test_listplaylistinfo_without_quotes(self):
self.core.stored_playlists.playlists = [
Playlist(name='name', tracks=[Track(uri='file:///dev/urandom')])]
self.sendRequest(u'listplaylistinfo name')
self.assertInResponse(u'file: file:///dev/urandom')
self.assertInResponse(u'Track: 0')
self.assertNotInResponse(u'Pos: 0')
self.assertInResponse(u'OK')
def test_listplaylistinfo_fails_if_no_playlist_is_found(self): def test_listplaylistinfo_fails_if_no_playlist_is_found(self):
self.sendRequest(u'listplaylistinfo "name"') self.sendRequest(u'listplaylistinfo "name"')
self.assertEqualResponse( self.assertEqualResponse(