~mmcg069/software-center/bug628714

« back to all changes in this revision

Viewing changes to test/test_cat_parsing.py

  • Committer: Matthew McGowan
  • Date: 2010-09-06 10:43:04 UTC
  • mfrom: (1085.1.20 trunk)
  • Revision ID: matthew.joseph.mcgowan@gmail.com-20100906104304-m6eezhq88at2cpko
merge w trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import sys
 
4
import unittest
 
5
sys.path.insert(0,"../")
 
6
 
 
7
from softwarecenter.enums import *
 
8
from softwarecenter.utils import *
 
9
 
 
10
from softwarecenter.apt.aptcache import AptCache
 
11
from softwarecenter.db.database import StoreDatabase
 
12
from softwarecenter.view.catview import CategoriesView, Category, get_category_by_name
 
13
 
 
14
 
 
15
class TestCatParsing(unittest.TestCase):
 
16
    """ tests the "where is it in the menu" code """
 
17
 
 
18
    def setUp(self):
 
19
        cache = AptCache()
 
20
        cache.open()
 
21
        xapian_base_path = XAPIAN_BASE_PATH
 
22
        pathname = os.path.join(xapian_base_path, "xapian")
 
23
        self.db = StoreDatabase(pathname, cache)
 
24
        self.db.open()
 
25
        self.catview = CategoriesView()
 
26
        self.catview.db = self.db
 
27
        self.cats = self.catview.parse_applications_menu('/usr/share/app-install')
 
28
 
 
29
    def test_get_cat_by_name(self):
 
30
        cat = get_category_by_name(self.cats, 'Games')
 
31
        self.assertEqual(cat.untranslated_name, 'Games')
 
32
        cat = get_category_by_name(self.cats, 'Featured')
 
33
        self.assertEqual(cat.untranslated_name, 'Featured')
 
34
 
 
35
    def test_cat_has_flags(self):
 
36
        cat = get_category_by_name(self.cats, 'Featured')
 
37
        self.assertEqual(cat.flags[0], 'carousel-only')
 
38
 
 
39
 
 
40
if __name__ == "__main__":
 
41
    import logging
 
42
    logging.basicConfig(level=logging.DEBUG)
 
43
    unittest.main()