From 213b4064bddea6137014dc4265d17d58b83ba7c4 Mon Sep 17 00:00:00 2001 Message-Id: <213b4064bddea6137014dc4265d17d58b83ba7c4.1714867684.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sun, 25 Nov 2007 18:13:28 +0000 Subject: [PATCH] tests/queue.py: check that the queue is padded to the right length Organization: Straylight/Edgeware From: Richard Kettlewell --- tests/Makefile.am | 3 ++- tests/dbversion.py | 2 +- tests/dtest.py | 17 +++++++++++------ tests/files.py | 2 +- tests/queue.py | 31 +++++++++++++++++++++++++++++++ 5 files changed, 46 insertions(+), 9 deletions(-) create mode 100755 tests/queue.py diff --git a/tests/Makefile.am b/tests/Makefile.am index e79c021..962a320 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -21,5 +21,6 @@ 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 diff --git a/tests/dbversion.py b/tests/dbversion.py index d7f58a5..4fcdbd2 100755 --- a/tests/dbversion.py +++ b/tests/dbversion.py @@ -33,7 +33,7 @@ def test(): 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() diff --git a/tests/dtest.py b/tests/dtest.py index 3936935..7c0bae0 100644 --- a/tests/dtest.py +++ b/tests/dtest.py @@ -21,7 +21,7 @@ """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""" @@ -153,9 +153,10 @@ def stdtracks(): def common_setup(): remove_dir(testroot) os.mkdir(testroot) + global port + port = random.randint(49152, 65535) 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 @@ -178,7 +179,11 @@ tracklength *.mp3 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) @@ -187,7 +192,7 @@ def start_daemon(): 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 @@ -268,7 +273,7 @@ def run(module=None, report=True): except AssertionError, e: global failures failures += 1 - print e + print "assertion failed: %s" % e.message finally: stop_daemon() if report: diff --git a/tests/files.py b/tests/files.py index 3fc19f4..4765f7f 100755 --- a/tests/files.py +++ b/tests/files.py @@ -23,7 +23,7 @@ import dtest,time,disorder,sys 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() diff --git a/tests/queue.py b/tests/queue.py new file mode 100755 index 0000000..37e9132 --- /dev/null +++ b/tests/queue.py @@ -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() -- [mdw]