Add more tests for previous
This commit is contained in:
parent
168d62f7ba
commit
ce349e37da
@ -157,6 +157,8 @@ class BasePlaybackController(object):
|
||||
|
||||
@property
|
||||
def previous_track(self):
|
||||
playlist = self.backend.current_playlist.playlist
|
||||
|
||||
if self.current_track is None:
|
||||
return None
|
||||
|
||||
@ -164,8 +166,7 @@ class BasePlaybackController(object):
|
||||
return None
|
||||
|
||||
try:
|
||||
return self.backend.current_playlist.playlist.tracks[
|
||||
self.playlist_position - 1]
|
||||
return playlist.tracks[self.playlist_position - 1]
|
||||
except IndexError:
|
||||
return None
|
||||
|
||||
|
||||
@ -301,6 +301,15 @@ class BasePlaybackControllerTest(object):
|
||||
self.playback.previous()
|
||||
self.assertEqual(self.playback.current_track, tracks[0])
|
||||
|
||||
@populate_playlist
|
||||
def test_previous_more(self):
|
||||
tracks = self.backend.current_playlist.playlist.tracks
|
||||
self.playback.play() # At track 0
|
||||
self.playback.next() # At track 1
|
||||
self.playback.next() # At track 2
|
||||
self.playback.previous() # At track 1
|
||||
self.assertEqual(self.playback.current_track, tracks[1])
|
||||
|
||||
@populate_playlist
|
||||
def test_previous_triggers_playback(self):
|
||||
self.playback.play()
|
||||
@ -359,7 +368,16 @@ class BasePlaybackControllerTest(object):
|
||||
self.playback.next()
|
||||
self.assertEqual(self.playback.previous_track, tracks[0])
|
||||
|
||||
@populate_playlist
|
||||
def test_previous_track_after_previous(self):
|
||||
tracks = self.backend.current_playlist.playlist.tracks
|
||||
self.playback.play() # At track 0
|
||||
self.playback.next() # At track 1
|
||||
self.playback.next() # At track 2
|
||||
self.playback.previous() # At track 1
|
||||
self.assertEqual(self.playback.previous_track, tracks[0])
|
||||
|
||||
def test_previous_track_empty_playlist(self):
|
||||
raise NotImplementedError
|
||||
|
||||
@populate_playlist
|
||||
|
||||
Loading…
Reference in New Issue
Block a user