1
# Copyright (C) 2008-2009 Adam Olsen
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2, or (at your option)
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
# The developers of the Exaile media player hereby grant permission
19
# for non-GPL compatible GStreamer and Exaile plugins to be used and
20
# distributed together with GStreamer and Exaile. This permission is
21
# above and beyond the permissions granted by the GPL license by which
22
# Exaile is covered. If you modify this code, you may extend this
23
# exception to your version of the code, but you are not obligated to
24
# do so. If you do not wish to do so, delete this exception statement
26
from tests.base import BaseTestCase
28
from xl import collection
30
class CollectionTestCase(BaseTestCase):
32
tracks = list(self.collection.search(''))
33
assert len(tracks) == 15, "Number of tracks scanned is incorrect"
35
def testSaveLoad(self):
36
self.collection.save_to_location()
39
col = collection.Collection("TestCollection2", self.temp_col_loc)
40
tracks = list(col.search(''))
41
assert len(tracks) == 15, "Number of tracks scanned is incorrect"
44
l = col.get_libraries()
45
assert len(l) == 1, "Number of saved libraries is incorrect" + \
46
"\n\tExpected: 1 Found: %s" % len(l)
47
assert l[0].location == './tests/data', "Saved library is incorrect"
49
def testAllFieldSearch(self):
52
# search for a keyword in all fields
53
tracks = list(c.search('Black', sort_fields=('artist', 'album',
55
assert len(tracks) == 1, "Keyword search failed"
56
assert tracks[0]['title'][0].find('black') > -1, "Keyword search failed"
58
def testNotSearch(self):
59
tracks = list(self.collection.search(
61
artist=="TestArtist" NOT album="Second"
65
assert len(tracks) == 2, "Not search failed"