~ubuntu-branches/ubuntu/lucid/exaile/lucid

« back to all changes in this revision

Viewing changes to tests/collection.py

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2010-02-12 19:51:01 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20100212195101-8jt3tculxcl92e6v
Tags: 0.3.1~b1-0ubuntu1
* New upstream release.
* Adjust exaile.install for new plugins.
* debian/control:
 - Drop unneeded python-dev Build-Dep.
 - Bump Standards-Version to 3.8.4 
* debian/rules: No empty po files to delete.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008-2009 Adam Olsen 
2
 
#
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)
6
 
# any later version.
7
 
#
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.
12
 
#
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.
16
 
#
17
 
#
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 
25
 
# from your version.
26
 
from tests.base import BaseTestCase
27
 
import unittest, time
28
 
from xl import collection
29
 
 
30
 
class CollectionTestCase(BaseTestCase):
31
 
    def testCount(self):
32
 
        tracks = list(self.collection.search(''))
33
 
        assert len(tracks) == 15, "Number of tracks scanned is incorrect"
34
 
 
35
 
    def testSaveLoad(self):
36
 
        self.collection.save_to_location()
37
 
        
38
 
        # test col
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"
42
 
 
43
 
        # test libraries
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"
48
 
 
49
 
    def testAllFieldSearch(self):
50
 
        c = self.collection
51
 
 
52
 
        # search for a keyword in all fields
53
 
        tracks = list(c.search('Black', sort_fields=('artist', 'album',
54
 
            'tracknumber')))
55
 
        assert len(tracks) == 1, "Keyword search failed"
56
 
        assert tracks[0]['title'][0].find('black') > -1, "Keyword search failed"
57
 
 
58
 
    def testNotSearch(self):
59
 
        tracks = list(self.collection.search(
60
 
            """
61
 
                artist=="TestArtist" NOT album="Second"
62
 
            """
63
 
        ))
64
 
 
65
 
        assert len(tracks) == 2, "Not search failed"