1046.1.1
by Michael Vogt
start on "where is it" implementation |
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 |
1046.1.1
by Michael Vogt
start on "where is it" implementation |
4 |
import sys |
5 |
import unittest |
|
6 |
sys.path.insert(0,"../") |
|
7 |
||
1471
by Michael Vogt
* softwarecenter/paths.py: |
8 |
from softwarecenter.paths import XAPIAN_BASE_PATH |
1782.3.4
by Michael Vogt
tests/: make pyflakes clean, fixup test_build_from_software_center_agent() |
9 |
from softwarecenter.utils import GMenuSearcher |
1773.1.5
by Michael Vogt
move AptCache out of the source and info the pkginfo abstraction |
10 |
from softwarecenter.db.pkginfo import get_pkg_info |
1046.1.1
by Michael Vogt
start on "where is it" implementation |
11 |
from softwarecenter.db.database import StoreDatabase |
1782.3.4
by Michael Vogt
tests/: make pyflakes clean, fixup test_build_from_software_center_agent() |
12 |
from softwarecenter.db.application import Application |
1046.1.1
by Michael Vogt
start on "where is it" implementation |
13 |
|
14 |
||
15 |
class TestWhereIsit(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() |
1046.1.2
by Michael Vogt
move main_menu_path_for_desktop_file into utils.py |
20 |
cache.open() |
1046.1.1
by Michael Vogt
start on "where is it" implementation |
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 |
||
1831
by Michael Vogt
fix tests (mostly updating to the new enums style) |
26 |
# mvo: disabled for now (2011-06-06) because the new gnome-panel
|
27 |
# does not have "System" anymore and its not clear to me yet
|
|
28 |
# where those items will appear. Once that is settled it
|
|
29 |
# should be re-enabled
|
|
30 |
def disabled_for_now_test_where_is_it_in_system(self): |
|
1046.1.1
by Michael Vogt
start on "where is it" implementation |
31 |
app = Application("Hardware Drivers", "jockey-gtk") |
32 |
details = app.get_details(self.db) |
|
33 |
self.assertEqual(details.desktop_file, |
|
34 |
"/usr/share/app-install/desktop/jockey-gtk.desktop") |
|
35 |
# search the settings menu
|
|
1046.1.3
by Michael Vogt
cleanup and make searcher a class |
36 |
searcher = GMenuSearcher() |
37 |
found = searcher.get_main_menu_path(details.desktop_file) |
|
1831
by Michael Vogt
fix tests (mostly updating to the new enums style) |
38 |
self.assertEqual(found[0].get_name(), "Desktop") |
1046.1.2
by Michael Vogt
move main_menu_path_for_desktop_file into utils.py |
39 |
self.assertEqual(found[0].get_icon(), "preferences-other") |
40 |
self.assertEqual(found[1].get_name(), "Administration") |
|
41 |
self.assertEqual(found[1].get_icon(), "preferences-system") |
|
42 |
||
43 |
def test_where_is_it_in_applications(self): |
|
44 |
app = Application("Calculator", "gcalctool") |
|
45 |
details = app.get_details(self.db) |
|
46 |
self.assertEqual(details.desktop_file, |
|
2038
by Michael Vogt
* pyflakes fixes |
47 |
"/usr/share/app-install/desktop/gcalctool:gcalctool.desktop") |
1046.1.2
by Michael Vogt
move main_menu_path_for_desktop_file into utils.py |
48 |
# search the settings menu
|
1046.1.3
by Michael Vogt
cleanup and make searcher a class |
49 |
searcher = GMenuSearcher() |
1288
by Michael Vogt
test/test_where_is_it.py, test/data/fake-applications.menu: |
50 |
found = searcher.get_main_menu_path( |
51 |
details.desktop_file, |
|
52 |
[os.path.abspath("./data/fake-applications.menu")]) |
|
1046.1.2
by Michael Vogt
move main_menu_path_for_desktop_file into utils.py |
53 |
self.assertEqual(found[0].get_name(), "Applications") |
54 |
self.assertEqual(found[0].get_icon(), "applications-other") |
|
55 |
self.assertEqual(found[1].get_name(), "Accessories") |
|
56 |
self.assertEqual(found[1].get_icon(), "applications-utilities") |
|
1197
by Michael Vogt
fix where-is-it for kde4 apps (LP: #635684) |
57 |
|
58 |
def test_where_is_it_kde4(self): |
|
59 |
app = Application("", "ark") |
|
60 |
details = app.get_details(self.db) |
|
61 |
self.assertEqual(details.desktop_file, |
|
2038
by Michael Vogt
* pyflakes fixes |
62 |
"/usr/share/app-install/desktop/ark:kde4__ark.desktop") |
1197
by Michael Vogt
fix where-is-it for kde4 apps (LP: #635684) |
63 |
# search the settings menu
|
64 |
searcher = GMenuSearcher() |
|
1288
by Michael Vogt
test/test_where_is_it.py, test/data/fake-applications.menu: |
65 |
found = searcher.get_main_menu_path( |
66 |
details.desktop_file, |
|
67 |
[os.path.abspath("./data/fake-applications.menu")]) |
|
1197
by Michael Vogt
fix where-is-it for kde4 apps (LP: #635684) |
68 |
self.assertEqual(found[0].get_name(), "Applications") |
69 |
self.assertEqual(found[0].get_icon(), "applications-other") |
|
70 |
self.assertEqual(found[1].get_name(), "Accessories") |
|
71 |
self.assertEqual(found[1].get_icon(), "applications-utilities") |
|
1046.1.1
by Michael Vogt
start on "where is it" implementation |
72 |
|
73 |
||
74 |
if __name__ == "__main__": |
|
75 |
import logging |
|
76 |
logging.basicConfig(level=logging.DEBUG) |
|
77 |
unittest.main() |