Implement and test 'listplaylist' and 'listplaylistinfo'
This commit is contained in:
parent
fda997b6a4
commit
ca7152d62c
@ -464,7 +464,11 @@ class MpdHandler(object):
|
||||
file: relative/path/to/file2.ogg
|
||||
file: relative/path/to/file3.mp3
|
||||
"""
|
||||
raise MpdNotImplemented # TODO
|
||||
try:
|
||||
return ['file: %s' % t.uri
|
||||
for t in self.backend.stored_playlists.get_by_name(name).tracks]
|
||||
except KeyError, e:
|
||||
raise MpdAckError(e)
|
||||
|
||||
@handle_pattern(r'^listplaylistinfo "(?P<name>[^"]+)"$')
|
||||
def _listplaylistinfo(self, name):
|
||||
@ -480,8 +484,11 @@ class MpdHandler(object):
|
||||
Standard track listing, with fields: file, Time, Title, Date,
|
||||
Album, Artist, Track
|
||||
"""
|
||||
return self.backend.stored_playlists.playlist.mpd_format(
|
||||
search_result=True)
|
||||
try:
|
||||
return self.backend.stored_playlists.get_by_name(name).mpd_format(
|
||||
search_result=True)
|
||||
except KeyError, e:
|
||||
raise MpdAckError(e)
|
||||
|
||||
@handle_pattern(r'^listplaylists$')
|
||||
def _listplaylists(self):
|
||||
|
||||
@ -603,15 +603,32 @@ class CurrentPlaylistHandlerTest(unittest.TestCase):
|
||||
|
||||
class StoredPlaylistsHandlerTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.h = handler.MpdHandler(backend=DummyBackend())
|
||||
self.b = DummyBackend()
|
||||
self.h = handler.MpdHandler(backend=self.b)
|
||||
|
||||
def test_listplaylist(self):
|
||||
self.b.stored_playlists.playlists = [
|
||||
Playlist(name='name', tracks=[Track(uri='file:///dev/urandom')])]
|
||||
result = self.h.handle_request(u'listplaylist "name"')
|
||||
self.assert_(u'ACK Not implemented' in result)
|
||||
self.assert_(u'file: file:///dev/urandom' in result)
|
||||
self.assert_(u'OK' in result)
|
||||
|
||||
def test_listplaylist_fails_if_no_playlist_is_found(self):
|
||||
result = self.h.handle_request(u'listplaylist "name"')
|
||||
self.assert_(u'ACK Name "name" not found' in result)
|
||||
|
||||
def test_listplaylistinfo(self):
|
||||
self.b.stored_playlists.playlists = [
|
||||
Playlist(name='name', tracks=[Track(uri='file:///dev/urandom')])]
|
||||
result = self.h.handle_request(u'listplaylistinfo "name"')
|
||||
self.assert_(u'ACK Not implemented' in result)
|
||||
self.assert_(u'file: file:///dev/urandom' in result)
|
||||
self.assert_(u'Track: 0' in result)
|
||||
self.assert_(u'Pos: 0' not in result)
|
||||
self.assert_(u'OK' in result)
|
||||
|
||||
def test_listplaylistinfo_fails_if_no_playlist_is_found(self):
|
||||
result = self.h.handle_request(u'listplaylistinfo "name"')
|
||||
self.assert_(u'ACK Name "name" not found' in result)
|
||||
|
||||
def test_listplaylists(self):
|
||||
result = self.h.handle_request(u'listplaylists')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user