Add test shuffle and shuffle method

This commit is contained in:
Thomas Adamcik 2010-02-07 20:34:43 +01:00
parent 94017550df
commit aafde26643
2 changed files with 20 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import logging
import random
import time
from mopidy.exceptions import MpdNotImplemented
@ -44,11 +45,16 @@ class BaseCurrentPlaylistController(object):
def remove(self, position):
tracks = self.playlist.tracks
del tracks[position]
self.playlist = Playlist(tracks=tracks)
def shuffle(self, start=None, end=None):
tracks = self.playlist.tracks
random.shuffle(tracks)
self.playlist = Playlist(tracks=tracks)
class BasePlaybackController(object):
PAUSED = 'paused'
PLAYING = 'playing'

View File

@ -1,3 +1,5 @@
import random
from mopidy.models import Track, Playlist
def populate_playlist(func):
@ -86,6 +88,17 @@ class BaseCurrentPlaylistControllerTest(object):
self.assertNotEqual(track, self.controller.playlist.tracks[1])
@populate_playlist
def test_shuffle_all(self):
tracks = self.controller.playlist.tracks
random.seed(1)
self.controller.shuffle()
shuffled_tracks = self.controller.playlist.tracks
self.assertNotEqual(tracks, shuffled_tracks)
self.assertEqual(set(tracks), set(shuffled_tracks))
class BasePlaybackControllerTest(object):
uris = []
backend_class = None