core: Make tracklist.append() return the appended TlTracks
This commit is contained in:
parent
02b225eb6e
commit
fff70c46a6
@ -111,6 +111,11 @@ backends:
|
||||
- The Spotify backend now returns the track if you search for the Spotify track
|
||||
URI. (Fixes: :issue:`233`)
|
||||
|
||||
- :meth:`mopidy.core.TracklistController.append` now returns a list of the
|
||||
:class:`mopidy.models.TlTrack` instances that was added to the tracklist.
|
||||
This makes it easier to start playing one of the tracks that was just
|
||||
appended to the tracklist.
|
||||
|
||||
**Bug fixes**
|
||||
|
||||
- :issue:`218`: The MPD commands ``listplaylist`` and ``listplaylistinfo`` now
|
||||
|
||||
@ -92,13 +92,17 @@ class TracklistController(object):
|
||||
|
||||
:param tracks: tracks to append
|
||||
:type tracks: list of :class:`mopidy.models.Track`
|
||||
:rtype: list of class:`mopidy.models.TlTrack`
|
||||
"""
|
||||
tl_tracks = []
|
||||
for track in tracks:
|
||||
self.add(track, increase_version=False)
|
||||
tl_tracks.append(self.add(track, increase_version=False))
|
||||
|
||||
if tracks:
|
||||
self.version += 1
|
||||
|
||||
return tl_tracks
|
||||
|
||||
def clear(self):
|
||||
"""Clear the current playlist."""
|
||||
self._tl_tracks = []
|
||||
|
||||
@ -153,10 +153,13 @@ class TracklistControllerTest(object):
|
||||
self.assertEqual(self.playback.state, PlaybackState.STOPPED)
|
||||
self.assertEqual(self.playback.current_track, None)
|
||||
|
||||
@populate_playlist
|
||||
def test_append_returns_the_tl_tracks_that_was_added(self):
|
||||
tl_tracks = self.controller.append(self.controller.tracks[1:2])
|
||||
self.assertEqual(tl_tracks[0][1], self.controller.tracks[1])
|
||||
|
||||
def test_index_returns_index_of_track(self):
|
||||
tl_tracks = []
|
||||
for track in self.tracks:
|
||||
tl_tracks.append(self.controller.add(track))
|
||||
tl_tracks = self.controller.append(self.tracks)
|
||||
self.assertEquals(0, self.controller.index(tl_tracks[0]))
|
||||
self.assertEquals(1, self.controller.index(tl_tracks[1]))
|
||||
self.assertEquals(2, self.controller.index(tl_tracks[2]))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user