chiark / gitweb /
tests/queue.py: check that the queue is padded to the right length
authorRichard Kettlewell <rjk@greenend.org.uk>
Sun, 25 Nov 2007 18:13:28 +0000 (18:13 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sun, 25 Nov 2007 18:13:28 +0000 (18:13 +0000)
tests/Makefile.am
tests/dbversion.py
tests/dtest.py
tests/files.py
tests/queue.py [new file with mode: 0755]

index e79c02186d33a6c9e7fef70554e3dfaadb397bc8..962a320464099268225e14e6dfab55dcf6278573 100644 (file)
@@ -21,5 +21,6 @@
 check:
        ${PYTHON} ${srcdir}/alltests
 
 check:
        ${PYTHON} ${srcdir}/alltests
 
-EXTRA_DIST=alltests dtest.py nothing.py version.py dbversion.py search.py
+EXTRA_DIST=alltests dtest.py nothing.py version.py dbversion.py search.py \
+       queue.py
 
 
index d7f58a59f6a5b3a8e63a5bb5d1724301544c9efb..4fcdbd29eb0958b7fd243ee2c2e5765f7525d453 100755 (executable)
@@ -33,7 +33,7 @@ def test():
     dtest.copyfile(configsave, config)
     print "Testing daemon manages to upgrade..."
     dtest.start_daemon()
     dtest.copyfile(configsave, config)
     print "Testing daemon manages to upgrade..."
     dtest.start_daemon()
-    assert dtest.check_files() == 0
+    assert dtest.check_files() == 0, "dtest.check_files"
 
 if __name__ == '__main__':
     dtest.run()
 
 if __name__ == '__main__':
     dtest.run()
index 3936935b463d02ac4a606ade4154f99fd7b438b3..7c0bae000445883bde64fcbea33e7ee77371ce4b 100644 (file)
@@ -21,7 +21,7 @@
 
 """Utility module used by tests"""
 
 
 """Utility module used by tests"""
 
-import os,os.path,subprocess,sys,re,time,unicodedata
+import os,os.path,subprocess,sys,re,time,unicodedata,random
 
 def fatal(s):
     """Write an error message and exit"""
 
 def fatal(s):
     """Write an error message and exit"""
@@ -153,9 +153,10 @@ def stdtracks():
 def common_setup():
     remove_dir(testroot)
     os.mkdir(testroot)
 def common_setup():
     remove_dir(testroot)
     os.mkdir(testroot)
+    global port
+    port = random.randint(49152, 65535)
     open("%s/config" % testroot, "w").write(
     open("%s/config" % testroot, "w").write(
-    """player *.ogg shell 'echo "$TRACK" >> %s/played.log'
-home %s
+    """home %s
 collection fs UTF-8 %s/tracks
 scratch %s/scratch.ogg
 gap 0
 collection fs UTF-8 %s/tracks
 scratch %s/scratch.ogg
 gap 0
@@ -178,7 +179,11 @@ tracklength *.mp3 disorder-tracklength
 tracklength *.ogg disorder-tracklength
 tracklength *.wav disorder-tracklength
 tracklength *.flac disorder-tracklength
 tracklength *.ogg disorder-tracklength
 tracklength *.wav disorder-tracklength
 tracklength *.flac disorder-tracklength
-""" % (testroot, testroot, testroot, testroot, top_builddir, top_builddir))
+speaker_backend network
+broadcast 127.0.0.1 %d
+broadcast_from 127.0.0.1 %d
+""" % (testroot, testroot, testroot, top_builddir, top_builddir,
+       port, port + 1))
     copyfile("%s/sounds/scratch.ogg" % top_srcdir,
              "%s/scratch.ogg" % testroot)
 
     copyfile("%s/sounds/scratch.ogg" % top_srcdir,
              "%s/scratch.ogg" % testroot)
 
@@ -187,7 +192,7 @@ def start_daemon():
 
 Start the daemon."""
     global daemon, errs
 
 Start the daemon."""
     global daemon, errs
-    assert daemon == None
+    assert daemon == None, "no daemon running"
     print " starting daemon"
     # remove the socket if it exists
     socket = "%s/socket" % testroot
     print " starting daemon"
     # remove the socket if it exists
     socket = "%s/socket" % testroot
@@ -268,7 +273,7 @@ def run(module=None, report=True):
         except AssertionError, e:
             global failures
             failures += 1
         except AssertionError, e:
             global failures
             failures += 1
-            print e
+            print "assertion failed: %s" % e.message
     finally:
         stop_daemon()
     if report:
     finally:
         stop_daemon()
     if report:
index 3fc19f4577d3c427bbeac17e98b10ccc4737d2fe..4765f7fdc978ebe41bf6cf331a4b9442cd14a3dd 100755 (executable)
@@ -23,7 +23,7 @@ import dtest,time,disorder,sys
 def test():
     """Check that the file listing comes out right"""
     dtest.start_daemon()
 def test():
     """Check that the file listing comes out right"""
     dtest.start_daemon()
-    assert dtest.check_files() == 0
+    assert dtest.check_files() == 0, "dtest.check_files"
 
 if __name__ == '__main__':
     dtest.run()
 
 if __name__ == '__main__':
     dtest.run()
diff --git a/tests/queue.py b/tests/queue.py
new file mode 100755 (executable)
index 0000000..37e9132
--- /dev/null
@@ -0,0 +1,31 @@
+#! /usr/bin/env python
+#
+# This file is part of DisOrder.
+# Copyright (C) 2007 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
+# the Free Software Foundation; either version 2 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.
+#
+# 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
+#
+import dtest,time,disorder
+
+def test():
+    """Ask the server its version number"""
+    dtest.start_daemon()
+    c = disorder.client()
+    q = c.queue()
+    assert len(q) == 10, "queue is at proper length"
+
+if __name__ == '__main__':
+    dtest.run()