From 5d9fd5b625b7e5a616adfb22ebea51e126e11e08 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 14 Aug 2010 14:42:44 +0200 Subject: [PATCH] MPD: Update tests and fix 'playlistfind' --- docs/changes.rst | 2 ++ mopidy/frontends/mpd/protocol/current_playlist.py | 5 ++++- tests/frontends/mpd/current_playlist_test.py | 6 +++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/changes.rst b/docs/changes.rst index 4ee8cf7f..d3ed3db2 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -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: diff --git a/mopidy/frontends/mpd/protocol/current_playlist.py b/mopidy/frontends/mpd/protocol/current_playlist.py index 30acbe89..c10d1dad 100644 --- a/mopidy/frontends/mpd/protocol/current_playlist.py +++ b/mopidy/frontends/mpd/protocol/current_playlist.py @@ -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 diff --git a/tests/frontends/mpd/current_playlist_test.py b/tests/frontends/mpd/current_playlist_test.py index e42077df..6b5c822e 100644 --- a/tests/frontends/mpd/current_playlist_test.py +++ b/tests/frontends/mpd/current_playlist_test.py @@ -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):