2a62fa5d878b83f987d5f97b478f3ca63acf67df
[jamaendo] / tests / testicle
1 #!/usr/bin/env python
2 # runs tons of test queries against the API,
3 # sleeping between each and printing the result
4
5 # debugging hack - add . to path
6 import os, sys
7 local_module_dir = os.path.join(os.path.dirname(sys.argv[0]), '..')
8 if os.path.isdir(local_module_dir):
9     sys.path.append(os.path.abspath(local_module_dir))
10
11 import time
12
13 import jamaendo as api2
14
15 class Tests(object):
16     def XXXtestSearchArtists(self):
17         result = api2.search_artists('porn')
18         print "Result:", result
19         print "Cache:", api2._artists
20
21     def XXXtestSearchAlbums(self):
22         result = api2.search_albums('porn')
23         print "Result:", result
24         print "Cache:", api2._albums
25
26     def XXXtestSearchTracks(self):
27         result = api2.search_tracks('porn')
28         print "Result:", result
29         print "Cache:", api2._tracks
30
31     def XXXtestAlbumsOfTheWeek(self):
32         result = api2.albums_of_the_week()
33         print "Result:", result
34         print "Cache:", api2._albums
35
36     def XXXtestNewReleases(self):
37         result = api2.new_releases()
38         print "Result:", result
39         print "Cache:", api2._tracks
40
41     def XXXtestTracksOfTheWeek(self):
42         result = api2.tracks_of_the_week()
43         print "Result:", result
44         print "Cache:", api2._tracks
45
46     def XXXtestStarredRadios(self):
47         result = api2.starred_radios()
48         print "Result:", result
49
50     def XXXtestGetRadio283(self):
51         result = api2.get_radio(283)
52         print "Result:", result
53
54     def testGetRadioTracks283(self):
55         result = api2.get_radio_tracks(283)
56         print "Result:", result
57
58     def XXXtestGetArtist91(self):
59         result = api2.get_artist(91)
60         print "Result:", result
61
62     def XXXtestGetAlbum27865(self):
63         result = api2.get_album(27865)
64         print "Result:", result
65
66     def XXXtestGetTrack353341(self):
67         result = api2.get_track(353341)
68         print "Result:", result
69
70     def XXXtestGetTracks27865(self):
71         result = api2.get_tracks(27865)
72         print "Result:", result
73
74     def XXXtestGetAlbums91(self):
75         result = api2.get_albums(91)
76         print "Result:", result
77
78     def XXXtestFavoriteAlbumsKegie(self):
79         result = api2.favorite_albums('kegie')
80         print "Result:", result
81
82     def XXXtestGetAlbumCover27865(self):
83         result = api2.get_album_cover(27865)
84         print "Result:", result
85
86     def XXXtestGetAlbumCoverAsync27865(self):
87         self.got_cover = False
88         def gotit(cover):
89             print "Got:", cover
90             self.got_cover = True
91         api2.get_album_cover_async(gotit, 27865)
92         while not self.got_cover:
93             print "Waiting for cover..."
94             time.sleep(4)
95
96 import traceback
97
98 def main():
99     for name in Tests.__dict__.keys():
100         if name.startswith('test'):
101             print "Running %s" % (name)
102             try:
103                 t = Tests()
104                 getattr(t, name)()
105             except Exception, e:
106                 traceback.print_exc()
107             print "Waiting..."
108             time.sleep(10)
109
110 if __name__=="__main__":
111     main()