Add prav_track and tests

This commit is contained in:
Thomas Adamcik 2010-02-14 03:03:36 +01:00
parent eb65afee1b
commit a7571ef6f2
2 changed files with 30 additions and 0 deletions

View File

@ -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

View File

@ -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])