1
from tests.base import BaseTestCase
2
from xl import playlist
5
class BasePlaylistTestCase(BaseTestCase):
11
class SmartPlaylistTestCase(BasePlaylistTestCase):
13
BasePlaylistTestCase.setUp(self)
15
self.sp_loc = ".testtemp/sp_exaile%s.playlist" % \
16
hashlib.md5(str(time.time())).hexdigest()
17
self.sp = playlist.SmartPlaylist(collection=self.collection)
18
self.sp.add_param("artist", "=", "TestArtist")
19
self.sp.add_param("album", "!=", "First")
21
def testSearch(self, sp=None):
22
if not sp: sp = self.sp
25
tracks = p.get_tracks()
27
for i, track in enumerate(tracks):
28
assert i+1 == track.get_track(), \
29
"SmartPlaylist search failed"
31
def testSaveLoad(self):
32
self.sp.set_or_match(True)
33
self.sp.save_to_location(self.sp_loc)
36
sp = playlist.SmartPlaylist(collection=self.collection)
37
sp.load_from_location(self.sp_loc)
39
assert sp.get_or_match() == True, "Loading saved smart playlist failed"
40
sp.set_or_match(False)
43
self.sp.set_or_match(False)
45
def testReturnLimit(self):
46
sp = playlist.SmartPlaylist(collection=self.collection)
47
sp.set_return_limit(2)
51
assert len(p) == 2, "Return limit test failed"
53
def testRandomSort(self):
54
sp = playlist.SmartPlaylist(collection=self.collection)
55
sp.set_random_sort(True)
60
start = p.get_tracks()
62
# if it's not different in 50 iterations, something *has* to be wrong
65
if start != p.get_tracks():
69
assert check == True, "Random sort did not work in 50 iterations"