From 44309345db3f72721bd41bc23fe72bd325146e6b Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Mon, 2 Aug 2010 14:27:57 +0200 Subject: [PATCH] Update 'addid' to return CPID instead of GID --- mopidy/mpd/frontend.py | 4 ++-- tests/mpd/current_playlist_test.py | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/mopidy/mpd/frontend.py b/mopidy/mpd/frontend.py index 7aa5d6e0..b8c4d098 100644 --- a/mopidy/mpd/frontend.py +++ b/mopidy/mpd/frontend.py @@ -273,8 +273,8 @@ class MpdFrontend(object): raise MpdNoExistError(u'No such song', command=u'addid') if songpos and songpos > len(self.backend.current_playlist.tracks): raise MpdArgError(u'Bad song index', command=u'addid') - self.backend.current_playlist.add(track, at_position=songpos) - return ('Id', track.id) + cp_track = self.backend.current_playlist.add(track, at_position=songpos) + return ('Id', cp_track[0]) @handle_pattern(r'^delete "(?P\d+):(?P\d+)*"$') def _current_playlist_delete_range(self, start, end=None): diff --git a/tests/mpd/current_playlist_test.py b/tests/mpd/current_playlist_test.py index 09e61b63..5a7b6ca4 100644 --- a/tests/mpd/current_playlist_test.py +++ b/tests/mpd/current_playlist_test.py @@ -29,7 +29,7 @@ class CurrentPlaylistHandlerTest(unittest.TestCase): u'ACK [50@0] {add} directory or file not found') def test_addid_without_songpos(self): - needle = Track(uri='dummy://foo', id=137) + needle = Track(uri='dummy://foo') self.b.library._library = [Track(), Track(), needle, Track()] self.b.current_playlist.load( [Track(), Track(), Track(), Track(), Track()]) @@ -37,11 +37,12 @@ class CurrentPlaylistHandlerTest(unittest.TestCase): result = self.h.handle_request(u'addid "dummy://foo"') self.assertEqual(len(self.b.current_playlist.tracks), 6) self.assertEqual(self.b.current_playlist.tracks[5], needle) - self.assert_(u'Id: 137' in result) + self.assert_(u'Id: %d' % self.b.current_playlist.cp_tracks[5][0] + in result) self.assert_(u'OK' in result) def test_addid_with_songpos(self): - needle = Track(uri='dummy://foo', id=137) + needle = Track(uri='dummy://foo') self.b.library._library = [Track(), Track(), needle, Track()] self.b.current_playlist.load( [Track(), Track(), Track(), Track(), Track()]) @@ -49,7 +50,8 @@ class CurrentPlaylistHandlerTest(unittest.TestCase): result = self.h.handle_request(u'addid "dummy://foo" "3"') self.assertEqual(len(self.b.current_playlist.tracks), 6) self.assertEqual(self.b.current_playlist.tracks[3], needle) - self.assert_(u'Id: 137' in result) + self.assert_(u'Id: %d' % self.b.current_playlist.cp_tracks[3][0] + in result) self.assert_(u'OK' in result) def test_addid_with_songpos_out_of_bounds_should_ack(self):