3 # This file is part of DisOrder.
4 # Copyright (C) 2007, 2008 Richard Kettlewell
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 import dtest,time,disorder,re,sys
22 """Play some tracks"""
25 dtest.rescan() # ensure all files are scanned
28 assert c.random_enabled() == False
29 track = u"%s/Joe Bloggs/First Album/02:Second track.ogg" % dtest.tracks
30 print " adding track to queue"
32 assert c.enabled() == False
34 print " checking track turned up in queue"
36 ts = filter(lambda t: t['track'] == track and 'submitter' in t, q)
37 assert len(ts) == 1, "checking track appears exactly once in queue"
39 assert t['submitter'] == u'fred', "check queue submitter"
41 print " waiting for track"
43 assert c.enabled() == True
47 while not((p is not None and p['id'] == i)
48 or (len(filter(lambda t: t['track'] == track
49 and 'submitter' in t, r)) > 0)) and limit > 0:
54 assert limit > 0, "check track did complete in a reasonable time"
55 print " checking track turned up in recent list"
56 while (p is not None and p['id'] == i):
60 ts = filter(lambda t: t['track'] == track and 'submitter' in t, r)
61 assert len(ts) == 1, "check track appears exactly once in recent"
63 assert t['submitter'] == u'fred', "check recent entry submitter"
65 print " testing scratches"
68 while scratchlimit > 0:
71 print " starting a track"
76 print " track played too quickly, trying again..."
78 print " scratching track"
81 print " waiting for track to finish"
84 while (p is not None and p['id'] == i) and limit > 0:
88 assert limit > 0, "check track finishes in a reasonable period"
89 print " checking scratched track turned up in recent list"
91 ts = filter(lambda t: t['id'] == i, r)
92 assert len(ts) == 1, "check scratched track appears exactly once in recent"
93 if ts[0]['state'] == 'ok':
94 print " track played too quickly, trying again..."
96 assert ts[0]['state'] == 'scratched', "checking track scratched"
99 # TODO this is really not a great approach!
100 print " didn't complete in a reasonable time"
102 print " waiting for scratch to complete"
107 assert p is None, "checking nothing is playing"
108 assert c.enabled() == True
110 assert c.random_enabled() == True
112 if __name__ == '__main__':