From f5eb2affdc1c88c71b4d66598dfc14216b22730f Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Sun, 2 Dec 2007 15:13:33 +0000 Subject: [PATCH] disorder.py: - dictionary keys in disorder.py are always strings (not unicode strings) - the config file is optional New tests/play.py. Organization: Straylight/Edgeware From: Richard Kettlewell --- python/disorder.py.in | 5 ++-- tests/Makefile.am | 3 +-- tests/play.py | 57 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 4 deletions(-) create mode 100755 tests/play.py diff --git a/python/disorder.py.in b/python/disorder.py.in index a8afcba..9585438 100644 --- a/python/disorder.py.in +++ b/python/disorder.py.in @@ -231,7 +231,7 @@ def _list2dict(l): while True: k = i.next() v = i.next() - d[k] = v + d[str(k)] = v except StopIteration: pass return d @@ -294,7 +294,8 @@ class client: home = pw.pw_dir privconf = _configfile + "." + pw.pw_name passfile = home + os.sep + ".disorder" + os.sep + "passwd" - self._readfile(_configfile) + if os.path.exists(_configfile): + self._readfile(_configfile) if os.path.exists(privconf): self._readfile(privconf) if os.path.exists(passfile) and _userconf: diff --git a/tests/Makefile.am b/tests/Makefile.am index 56c64be..c865c58 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -22,5 +22,4 @@ check: ${PYTHON} ${srcdir}/alltests EXTRA_DIST=alltests dtest.py nothing.py version.py dbversion.py search.py \ - queue.py dump.py - + queue.py dump.py play.py diff --git a/tests/play.py b/tests/play.py new file mode 100755 index 0000000..b02ffce --- /dev/null +++ b/tests/play.py @@ -0,0 +1,57 @@ +#! /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,re + +def test(): + """Play some tracks""" + dtest.start_daemon() + c = disorder.client() + track = u"%s/Joe Bloggs/First Album/02:Second track.ogg" % dtest.tracks + print "adding track to queue" + c.play(track) + print "checking track turned up in queue" + q = c.queue() + ts = filter(lambda t: t['track'] == track and 'submitter' in t, q) + assert len(ts) == 1 + t = ts[0] + assert t['submitter'] == u'fred', "check queue submitter" + i = t['id'] + print "waiting for track to play" + p = c.playing() + while p is None or p['id'] != i: + time.sleep(1) + p = c.playing() + print "waiting for track to finish" + p = c.playing() + while p is not None and p['id'] == i: + time.sleep(1) + p = c.playing() + print "checking track turned up in recent list" + q = c.recent() + ts = filter(lambda t: t['track'] == track and 'submitter' in t, q) + assert len(ts) == 1 + t = ts[0] + assert t['submitter'] == u'fred', "check recent entry submitter" + + + +if __name__ == '__main__': + dtest.run() -- [mdw]