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
|
- Fixed delete current playing track from playlist, which crashed several
|
||||||
clients.
|
clients.
|
||||||
- Implement ``seek`` and ``seekid``.
|
- Implement ``seek`` and ``seekid``.
|
||||||
|
- Fix ``playlistfind`` output so the correct song is played when playing
|
||||||
|
songs directly from search results in GMPC.
|
||||||
|
|
||||||
- Backends:
|
- Backends:
|
||||||
|
|
||||||
|
|||||||
@ -173,7 +173,10 @@ def playlistfind(frontend, tag, needle):
|
|||||||
if tag == 'filename':
|
if tag == 'filename':
|
||||||
try:
|
try:
|
||||||
cp_track = frontend.backend.current_playlist.get(uri=needle)
|
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:
|
except LookupError:
|
||||||
return None
|
return None
|
||||||
raise MpdNotImplemented # TODO
|
raise MpdNotImplemented # TODO
|
||||||
|
|||||||
@ -195,14 +195,16 @@ class CurrentPlaylistHandlerTest(unittest.TestCase):
|
|||||||
result = self.h.handle_request(u'playlistfind "tag" "needle"')
|
result = self.h.handle_request(u'playlistfind "tag" "needle"')
|
||||||
self.assert_(u'ACK [0@0] {} Not implemented' in result)
|
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(
|
result = self.h.handle_request(
|
||||||
u'playlistfind "filename" "file:///dev/null"')
|
u'playlistfind "filename" "file:///dev/null"')
|
||||||
|
self.assertEqual(len(result), 1)
|
||||||
self.assert_(u'OK' in result)
|
self.assert_(u'OK' in result)
|
||||||
|
|
||||||
def test_playlistfind_by_filename_without_quotes(self):
|
def test_playlistfind_by_filename_without_quotes(self):
|
||||||
result = self.h.handle_request(
|
result = self.h.handle_request(
|
||||||
u'playlistfind filename "file:///dev/null"')
|
u'playlistfind filename "file:///dev/null"')
|
||||||
|
self.assertEqual(len(result), 1)
|
||||||
self.assert_(u'OK' in result)
|
self.assert_(u'OK' in result)
|
||||||
|
|
||||||
def test_playlistfind_by_filename_in_current_playlist(self):
|
def test_playlistfind_by_filename_in_current_playlist(self):
|
||||||
@ -211,6 +213,8 @@ class CurrentPlaylistHandlerTest(unittest.TestCase):
|
|||||||
result = self.h.handle_request(
|
result = self.h.handle_request(
|
||||||
u'playlistfind filename "file:///exists"')
|
u'playlistfind filename "file:///exists"')
|
||||||
self.assert_(u'file: file:///exists' in result)
|
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)
|
self.assert_(u'OK' in result)
|
||||||
|
|
||||||
def test_playlistid_without_songid(self):
|
def test_playlistid_without_songid(self):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user