1085.3.2
by Matthew McGowan
add a simple test for category flags. |
1 |
#!/usr/bin/python
|
2 |
||
1782.3.4
by Michael Vogt
tests/: make pyflakes clean, fixup test_build_from_software_center_agent() |
3 |
import os |
1085.3.2
by Matthew McGowan
add a simple test for category flags. |
4 |
import sys |
5 |
import unittest |
|
6 |
sys.path.insert(0,"../") |
|
7 |
||
1782.3.4
by Michael Vogt
tests/: make pyflakes clean, fixup test_build_from_software_center_agent() |
8 |
from softwarecenter.paths import XAPIAN_BASE_PATH |
1085.3.2
by Matthew McGowan
add a simple test for category flags. |
9 |
|
10 |
from softwarecenter.db.database import StoreDatabase |
|
1773.1.5
by Michael Vogt
move AptCache out of the source and info the pkginfo abstraction |
11 |
from softwarecenter.db.pkginfo import get_pkg_info |
1773.3.19
by Michael Vogt
add categories backend |
12 |
from softwarecenter.db.categories import CategoriesParser, get_category_by_name |
1085.3.2
by Matthew McGowan
add a simple test for category flags. |
13 |
|
14 |
||
15 |
class TestCatParsing(unittest.TestCase): |
|
16 |
""" tests the "where is it in the menu" code """
|
|
17 |
||
18 |
def setUp(self): |
|
1773.1.5
by Michael Vogt
move AptCache out of the source and info the pkginfo abstraction |
19 |
cache = get_pkg_info() |
1085.3.2
by Matthew McGowan
add a simple test for category flags. |
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() |
|
1773.3.37
by Michael Vogt
merged from trunk and fixed imports |
25 |
self.catview = CategoriesParser(self.db) |
1085.3.2
by Matthew McGowan
add a simple test for category flags. |
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() |