Commit | Line | Data |
---|---|---|
fd2c0d95 | 1 | #! /usr/bin/env python |
27ed5a69 RK |
2 | # |
3 | # This file is part of DisOrder. | |
4 | # Copyright (C) 2008 Richard Kettlewell | |
5 | # | |
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. | |
10 | # | |
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. | |
15 | # | |
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 | |
19 | # USA | |
20 | # | |
21 | import dtest,disorder | |
22 | ||
23 | def test(): | |
24 | """Exercise alias logic""" | |
25 | dtest.start_daemon() | |
26 | dtest.create_user() | |
27 | dtest.rescan() | |
28 | c = disorder.client() | |
29 | ||
30 | print " creating an alias in new directory" | |
31 | track = "%s/misc/blahblahblah.ogg" % dtest.tracks | |
32 | c.set(track, | |
33 | "trackname_display_artist", | |
34 | "Fred Smith") | |
35 | c.set(track, | |
36 | "trackname_display_album", | |
37 | "wibble") | |
38 | ||
39 | print " checking it shows up in the right place" | |
40 | alias = "%s/Fred Smith/wibble/blahblahblah.ogg" % dtest.tracks | |
41 | files = c.files("%s/Fred Smith/wibble" % dtest.tracks) | |
42 | assert files == [alias] | |
43 | ||
44 | print " checking part calculation" | |
45 | artist = c.part(track, "display", "artist") | |
46 | assert artist == "Fred Smith", "checking artist part" | |
47 | album = c.part(track, "display", "album") | |
48 | assert album == "wibble", "checking album part" | |
49 | title = c.part(track, "display", "title") | |
50 | assert title == "blahblahblah", "checking title part" | |
51 | ||
52 | print " checking part calculation on alias" | |
53 | artist = c.part(alias, "display", "artist") | |
54 | assert artist == "Fred Smith", "checking artist part" | |
55 | album = c.part(alias, "display", "album") | |
56 | assert album == "wibble", "checking album part" | |
57 | title = c.part(alias, "display", "title") | |
58 | assert title == "blahblahblah", "checking title part" | |
59 | ||
60 | # See defect #20 | |
61 | print " checking that prefs always belong to the canonical name" | |
62 | c.set(alias, "wibble", "spong") | |
63 | value = c.get(track, "wibble") | |
64 | assert value == "spong", "checking pref ended up on resolved track" | |
65 | c.set(track, "foo", "bar") | |
66 | value = c.get(alias, "foo") | |
67 | assert value == "bar", "checking pref visible via alias" | |
68 | ||
69 | if __name__ == '__main__': | |
70 | dtest.run() |