8cf0943cf508e111227b500c6e0ea11ff95ae8f6
3 # This file is part of DisOrder.
4 # Copyright (C) 2007 Richard Kettlewell
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 import dtest
,time
,disorder
,re
24 """Exercise database dumper"""
27 track
= "%s/Joe Bloggs/First Album/02:Second track.ogg" % dtest
.tracks
28 dump
= "%s/dumpfile" % dtest
.testroot
29 print "setting a track pref"
30 c
.set(track
, "foo", "before")
31 assert c
.get(track
, "foo") == "before", "checking track foo=before"
32 print "setting a global pref"
33 c
.setglobal("foo", "before");
34 assert c
.getglobal("foo") == "before", "checking global foo=before"
36 c
.set(track
, "tags", "wibble")
37 print "checking track appears in tag search"
38 tracks
= c
.search(["tag:wibble"])
39 assert len(tracks
) == 1, "checking there is exactly one search result"
40 assert tracks
[0] == track
, "checking for right search result"
41 print "dumping database"
42 print dtest
.command(["disorder-dump", "--config", disorder
._configfile
,
44 print "changing track pref"
45 c
.set(track
, "foo", "after");
46 assert c
.get(track
, "foo") == "after", "checking track foo=before"
47 print "changing global pref"
48 c
.setglobal("foo", "after");
49 assert c
.getglobal("foo") == "after", "checking global foo=before"
50 print "adding fresh track pref"
51 c
.set(track
, "bar", "after")
52 print "adding fresh global pref"
53 c
.setglobal("bar", "after")
55 print "restoring database"
56 print dtest
.command(["disorder-dump", "--config", disorder
._configfile
,
60 print "checking track pref"
61 assert c
.get(track
, "foo") == "before", "checking track foo=before after undump"
62 print "checking global pref"
63 assert c
.getglobal("foo") == "before", "checking global foo=before after undump"
64 print "checking fresh track pref"
65 assert c
.get(track
, "bar") is None, "checking fresh track pref has gone"
66 print "checking fresh global pref"
67 assert c
.getglobal("bar") is None, "checking fresh global pref has gone"
68 print "checking tag search still works"
69 tracks
= c
.search(["tag:wibble"])
70 assert len(tracks
) == 1, "checking there is exactly one search result"
71 assert tracks
[0] == track
, "checking for right search result"
73 if __name__
== '__main__':