Add prav_track and tests
This commit is contained in:
parent
eb65afee1b
commit
a7571ef6f2
@ -127,3 +127,17 @@ class BasePlaybackController(object):
|
||||
self.playlist_position + 1]
|
||||
except IndexError:
|
||||
return None
|
||||
|
||||
@property
|
||||
def previous_track(self):
|
||||
if self.current_track is None:
|
||||
return None
|
||||
|
||||
if self.playlist_position - 1 < 0:
|
||||
return None
|
||||
|
||||
try:
|
||||
return self.backend.current_playlist.playlist.tracks[
|
||||
self.playlist_position - 1]
|
||||
except IndexError:
|
||||
return None
|
||||
|
||||
@ -261,3 +261,19 @@ class BasePlaybackControllerTest(object):
|
||||
tracks = self.backend.current_playlist.playlist.tracks
|
||||
self.playback.play()
|
||||
self.assertEqual(self.playback.next_track, tracks[1])
|
||||
|
||||
@populate_playlist
|
||||
def test_previous_track_before_play(self):
|
||||
self.assertEqual(self.playback.previous_track, None)
|
||||
|
||||
@populate_playlist
|
||||
def test_previous_track_after_play(self):
|
||||
self.playback.play()
|
||||
self.assertEqual(self.playback.previous_track, None)
|
||||
|
||||
@populate_playlist
|
||||
def test_previous_track_after_next(self):
|
||||
tracks = self.backend.current_playlist.playlist.tracks
|
||||
self.playback.play()
|
||||
self.playback.next()
|
||||
self.assertEqual(self.playback.previous_track, tracks[0])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user