MPD: Update tests and fix 'playlistfind'
This commit is contained in:
parent
908ad5016f
commit
5d9fd5b625
@ -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:
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user