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,sys
25 def check_search_results(terms, expected):
27 # We want a consistent encoding and ordering
28 print "terms: %s" % terms
29 got = client.search(terms)
30 got = map(dtest.nfc, got)
31 expected = map(lambda s: "%s/%s" % (dtest.tracks, s), expected)
32 expected = map(dtest.nfc, expected)
36 print "expected: %s" % expected
42 """Check that the search produces the right results"""
44 time.sleep(2) # give rescan a chance
46 client = disorder.client()
48 check_search_results(["first"],
49 ["Joe Bloggs/First Album/01:F\xC3\x8Crst track.ogg",
50 "Joe Bloggs/First Album/02:Second track.ogg",
51 "Joe Bloggs/First Album/03:ThI\xCC\x81rd track.ogg",
52 "Joe Bloggs/First Album/04:Fourth track.ogg",
53 "Joe Bloggs/First Album/05:Fifth track.ogg",
54 "Joe Bloggs/Second Album/01:First track.ogg",
55 "Joe Bloggs/Third Album/01:First_track.ogg"])
56 check_search_results(["second"],
57 ["Joe Bloggs/First Album/02:Second track.ogg",
58 "Joe Bloggs/Second Album/01:First track.ogg",
59 "Joe Bloggs/Second Album/02:Second track.ogg",
60 "Joe Bloggs/Second Album/03:Third track.ogg",
61 "Joe Bloggs/Second Album/04:Fourth track.ogg",
62 "Joe Bloggs/Second Album/05:Fifth track.ogg",
63 "Joe Bloggs/Third Album/02:Second_track.ogg"])
65 check_search_results(["first", "second"],
66 ["Joe Bloggs/First Album/02:Second track.ogg",
67 "Joe Bloggs/Second Album/01:First track.ogg"])
71 if __name__ == '__main__':