MPD: Update tests and fix 'playlistfind'

This commit is contained in:
Stein Magnus Jodal 2010-08-14 14:42:44 +02:00
parent 908ad5016f
commit 5d9fd5b625
3 changed files with 11 additions and 2 deletions

View File

@ -47,6 +47,8 @@ greatly improved MPD client support.
- Fixed delete current playing track from playlist, which crashed several
clients.
- Implement ``seek`` and ``seekid``.
- Fix ``playlistfind`` output so the correct song is played when playing
songs directly from search results in GMPC.
- Backends:

View File

@ -173,7 +173,10 @@ def playlistfind(frontend, tag, needle):
if tag == 'filename':
try:
cp_track = frontend.backend.current_playlist.get(uri=needle)
return cp_track[1].mpd_format()
(cpid, track) = cp_track
position = frontend.backend.current_playlist.cp_tracks.index(
cp_track)
return track.mpd_format(cpid=cpid, position=position)
except LookupError:
return None
raise MpdNotImplemented # TODO

View File

@ -195,14 +195,16 @@ class CurrentPlaylistHandlerTest(unittest.TestCase):
result = self.h.handle_request(u'playlistfind "tag" "needle"')
self.assert_(u'ACK [0@0] {} Not implemented' in result)
def test_playlistfind_by_filename(self):
def test_playlistfind_by_filename_not_in_current_playlist(self):
result = self.h.handle_request(
u'playlistfind "filename" "file:///dev/null"')
self.assertEqual(len(result), 1)
self.assert_(u'OK' in result)
def test_playlistfind_by_filename_without_quotes(self):
result = self.h.handle_request(
u'playlistfind filename "file:///dev/null"')
self.assertEqual(len(result), 1)
self.assert_(u'OK' in result)
def test_playlistfind_by_filename_in_current_playlist(self):
@ -211,6 +213,8 @@ class CurrentPlaylistHandlerTest(unittest.TestCase):
result = self.h.handle_request(
u'playlistfind filename "file:///exists"')
self.assert_(u'file: file:///exists' in result)
self.assert_(u'Id: 1' in result)
self.assert_(u'Pos: 0' in result)
self.assert_(u'OK' in result)
def test_playlistid_without_songid(self):