X-Git-Url: https://git.distorted.org.uk/~mdw/disorder/blobdiff_plain/6ce6b5a9430b1b8749d832ecabe840a7b65d74de..5e34540b562f91c7b383a307c32e1a159266dd11:/tests/play.py diff --git a/tests/play.py b/tests/play.py index 5c2df1b..3d09bd1 100755 --- a/tests/play.py +++ b/tests/play.py @@ -23,18 +23,19 @@ import dtest,time,disorder,re def test(): """Play some tracks""" dtest.start_daemon() + dtest.create_user() c = disorder.client() track = u"%s/Joe Bloggs/First Album/02:Second track.ogg" % dtest.tracks - print "adding track to queue" + print " adding track to queue" c.play(track) - print "checking track turned up in queue" + print " checking track turned up in queue" q = c.queue() ts = filter(lambda t: t['track'] == track and 'submitter' in t, q) assert len(ts) == 1, "checking track appears exactly once in queue" t = ts[0] assert t['submitter'] == u'fred', "check queue submitter" i = t['id'] - print "waiting for track" + print " waiting for track" p = c.playing() r = c.recent() while not((p is not None and p['id'] == i) @@ -42,7 +43,7 @@ def test(): time.sleep(1) p = c.playing() r = c.recent() - print "checking track turned up in recent list" + print " checking track turned up in recent list" while (p is not None and p['id'] == i): time.sleep(1) p = c.playing() @@ -51,6 +52,35 @@ def test(): assert len(ts) == 1, "check track appears exactly once in recent" t = ts[0] assert t['submitter'] == u'fred', "check recent entry submitter" + print " disabling play" + c.disable() + print " scratching current track" + p = c.playing() + i = p['id'] + c.scratch(i) + print " checking scratched track turned up in recent list" + while (p is not None and p['id'] == i): + time.sleep(1) + p = c.playing() + r = c.recent() + ts = filter(lambda t: t['id'] == i, r) + assert len(ts) == 1, "check scratched track appears exactly once in recent" + assert ts[0]['state'] == 'scratched', "checking track scratched" + print " waiting for scratch to complete" + while (p is not None and p['state'] == 'isscratch'): + time.sleep(1) + p = c.playing() + assert p is None, "checking nothing is playing" + c.random_disable() + assert c.random_enabled() == False + assert c.enabled() == False + c.enable() + assert c.enabled() == True + time.sleep(1) + p = c.playing() + assert p is None, "checking nothing playing when random disabled but playing enabled" + c.random_enable() + assert c.random_enabled() == True if __name__ == '__main__': dtest.run()