chiark / gitweb /
Account choose_list_in_flight correctly.
[disorder] / tests / queue.py
index cc0b619a31e719b97fc81640e08e4fb1694e9c17..dae37b47d473206d825940eb4e7c55796a6e5dbe 100755 (executable)
@@ -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
 #
 import dtest,time,disorder,re
 
+class wait_monitor(disorder.monitor):
+    def queue(self, q):
+        return False
+
 def test():
     """Check the queue is padded to the (default) configured length"""
     dtest.start_daemon()
+    dtest.create_user()
     c = disorder.client()
-    print " getting queue via python module"
+    print " disabling play"
+    c.disable()
+    print " waiting for queue to be populated..."
     q = c.queue()
-    assert len(q) == 10, "queue is at proper length"
+    while len(q) < 5:
+        print "  queue at %d tracks" % len(q)
+        wait_monitor().run()
+        q = c.queue()
     print " getting queue via disorder(1)"
     q = dtest.command(["disorder",
                        "--config", disorder._configfile, "--no-per-user-config",
                        "queue"])
     tracks = filter(lambda s: re.match("^track", s), q)
-    assert len(tracks) == 10, "queue is at proper length"
+    assert len(tracks) == 5, "queue is at proper length"
     print " disabling random play"
     c.random_disable()
     print " emptying queue"
@@ -43,9 +53,12 @@ def test():
     assert q == [], "checking queue is empty"
     print " enabling random play"
     c.random_enable()
-    print " checking queue refills"
+    print " waiting for queue to refill..."
     q = c.queue()
-    assert len(q) == 10, "queue is at proper length"
+    while len(q) < 5:
+        print "  queue at %d tracks" % len(q)
+        wait_monitor().run()
+        q = c.queue()
     print " disabling all play"
     c.random_disable()
     c.disable()