chiark / gitweb /
Tests terminate server with SIGTERM rather than trying to send a
[disorder] / tests / aliases.py
1 #! /usr/bin/env python
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 3 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,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU 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, see <http://www.gnu.org/licenses/>.
18 #
19 import dtest,disorder
20
21 def test():
22     """Exercise alias logic"""
23     dtest.start_daemon()
24     dtest.create_user()
25     dtest.rescan()
26     c = disorder.client()
27
28     print " creating an alias in new directory"
29     track = "%s/misc/blahblahblah.ogg" % dtest.tracks
30     c.set(track,
31           "trackname_display_artist",
32           "Fred Smith")
33     c.set(track,
34           "trackname_display_album",
35           "wibble")
36
37     print " checking it shows up in the right place"
38     alias = "%s/Fred Smith/wibble/blahblahblah.ogg" % dtest.tracks
39     files = c.files("%s/Fred Smith/wibble" % dtest.tracks)
40     assert files == [alias]
41
42     print " checking part calculation"
43     artist = c.part(track, "display", "artist")
44     assert artist == "Fred Smith", "checking artist part"
45     album = c.part(track, "display", "album")
46     assert album == "wibble", "checking album part"
47     title = c.part(track, "display", "title")
48     assert title == "blahblahblah", "checking title part"
49
50     print " checking part calculation on alias"
51     artist = c.part(alias, "display", "artist")
52     assert artist == "Fred Smith", "checking artist part"
53     album = c.part(alias, "display", "album")
54     assert album == "wibble", "checking album part"
55     title = c.part(alias, "display", "title")
56     assert title == "blahblahblah", "checking title part"
57
58     # See defect #20
59     print " checking that prefs always belong to the canonical name"
60     c.set(alias, "wibble", "spong")
61     value = c.get(track, "wibble")
62     assert value == "spong", "checking pref ended up on resolved track"
63     c.set(track, "foo", "bar")
64     value = c.get(alias, "foo")
65     assert value == "bar", "checking pref visible via alias"
66
67 if __name__ == '__main__':
68     dtest.run()