chiark / gitweb /
Merge playlist support.
[disorder] / tests / queue.py
index 4deb88d40de223eb3525ff1ee31ada1a5774746d..7503ac7adc17faf1c8fe10cff7f3c08a153dd133 100755 (executable)
@@ -1,44 +1,46 @@
 #! /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
+# 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
-# the Free Software Foundation; either version 2 of the License, or
+# the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
 #
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more details.
-#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-# USA
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 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()
-    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"
+    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"
@@ -49,9 +51,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()