X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/63ad732fd2031c8775ddf98cd538c8759c4537df..61682944f5d1fb2911de971b76a99cd57ec3c50a:/tests/queue.py diff --git a/tests/queue.py b/tests/queue.py index b26bdf3..7ed10a0 100755 --- a/tests/queue.py +++ b/tests/queue.py @@ -1,7 +1,7 @@ #! /usr/bin/env python # # This file is part of DisOrder. -# Copyright (C) 2007 Richard Kettlewell +# Copyright (C) 2007, 2008 Richard Kettlewell # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,6 +23,12 @@ import dtest,time,disorder,re def test(): """Check the queue is padded to the (default) configured length""" dtest.start_daemon() + dtest.create_user() + print " waiting for queue to be populated..." + class wait_monitor(disorder.monitor): + def queue(self, q): + return False + wait_monitor().run() c = disorder.client() print " getting queue via python module" q = c.queue() @@ -33,6 +39,46 @@ def test(): "queue"]) tracks = filter(lambda s: re.match("^track", s), q) assert len(tracks) == 10, "queue is at proper length" + print " disabling random play" + c.random_disable() + print " emptying queue" + for t in c.queue(): + c.remove(t['id']) + print " checking queue is now empty" + q = c.queue() + assert q == [], "checking queue is empty" + print " enabling random play" + c.random_enable() + print " checking queue refills" + q = c.queue() + assert len(q) == 10, "queue is at proper length" + print " disabling all play" + c.random_disable() + c.disable() + print " emptying queue" + for t in c.queue(): + c.remove(t['id']) + t1 = "%s/Joe Bloggs/Third Album/01:First_track.ogg" % dtest.tracks + t2 = "%s/Joe Bloggs/Third Album/02:Second_track.ogg" % dtest.tracks + t3 = "%s/Joe Bloggs/Third Album/02:Second_track.ogg" % dtest.tracks + print " adding tracks" + i1 = c.play(t1) + i2 = c.play(t2) + i3 = c.play(t3) + q = c.queue() + assert map(lambda e:e['id'], q) == [i1, i2, i3], "checking queue order(1)" + print " moving last track to start" + c.moveafter(None, [i3]) + q = c.queue() + assert map(lambda e:e['id'], q) == [i3, i1, i2], "checking queue order(2)" + print " moving two tracks" + c.moveafter(i1, [i2, i3]) + q = c.queue() + assert map(lambda e:e['id'], q) == [i1, i2 ,i3], "checking queue order(3)" + print " removing a track" + c.remove(i2) + q = c.queue() + assert map(lambda e:e['id'], q) == [i1 ,i3], "checking queue order(4)" if __name__ == '__main__': dtest.run()