Implement _current_playlist_swapid
This commit is contained in:
parent
b89a6fc46d
commit
d0916334d4
@ -517,7 +517,13 @@ class MpdHandler(object):
|
||||
|
||||
Swaps the positions of ``SONG1`` and ``SONG2`` (both song ids).
|
||||
"""
|
||||
raise MpdNotImplemented # TODO
|
||||
songid1 = int(songid1)
|
||||
songid2 = int(songid2)
|
||||
song1 = self.backend.current_playlist.get_by_id(songid1)
|
||||
song2 = self.backend.current_playlist.get_by_id(songid2)
|
||||
songpos1 = self.backend.current_playlist.playlist.tracks.index(song1)
|
||||
songpos2 = self.backend.current_playlist.playlist.tracks.index(song2)
|
||||
self._current_playlist_swap(songpos1, songpos2)
|
||||
|
||||
@handle_pattern(r'^$')
|
||||
def _empty(self):
|
||||
|
||||
@ -768,8 +768,17 @@ class CurrentPlaylistHandlerTest(unittest.TestCase):
|
||||
self.assert_(u'OK' in result)
|
||||
|
||||
def test_swapid(self):
|
||||
result = self.h.handle_request(u'swapid "10" "20"')
|
||||
self.assert_(u'ACK Not implemented' in result)
|
||||
self.b.current_playlist.load(Playlist(tracks=[
|
||||
Track(name='a'), Track(name='b', id=13), Track(name='c'),
|
||||
Track(name='d'), Track(name='e', id=29), Track(name='f')]))
|
||||
result = self.h.handle_request(u'swapid "13" "29"')
|
||||
self.assertEquals(self.b.current_playlist.playlist.tracks[0].name, 'a')
|
||||
self.assertEquals(self.b.current_playlist.playlist.tracks[1].name, 'e')
|
||||
self.assertEquals(self.b.current_playlist.playlist.tracks[2].name, 'c')
|
||||
self.assertEquals(self.b.current_playlist.playlist.tracks[3].name, 'd')
|
||||
self.assertEquals(self.b.current_playlist.playlist.tracks[4].name, 'b')
|
||||
self.assertEquals(self.b.current_playlist.playlist.tracks[5].name, 'f')
|
||||
self.assert_(u'OK' in result)
|
||||
|
||||
|
||||
class StoredPlaylistsHandlerTest(unittest.TestCase):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user