3
from gi.repository import Gtk, GObject
7
from testutils import setup_test_env
3
from tests.utils import (
10
9
from softwarecenter.enums import XapianValues, ActionButtons
10
from tests.gtk3.windows import get_test_window_availablepane
14
13
class TestCustomLists(unittest.TestCase):
16
def _debug(self, index, model, needle):
17
print ("Expected '%s' at index '%s', " +
18
"and custom list contained: '%s'") % (
19
needle, index, model[index][0].get_value(XapianValues.PKGNAME))
21
15
def assertPkgInListAtIndex(self, index, model, needle):
23
self.assertEqual(doc.get_value(XapianValues.PKGNAME),
24
needle, self._debug(index, model, needle))
16
doc_name = model[index][0].get_value(XapianValues.PKGNAME)
17
msg = "Expected %r at index %r, and custom list contained: %r"
18
self.assertEqual(doc_name, needle, msg % (needle, index, doc_name))
26
20
def test_custom_lists(self):
27
from softwarecenter.ui.gtk3.panes.availablepane import get_test_window
28
win = get_test_window()
21
win = get_test_window_availablepane()
22
self.addCleanup(win.destroy)
29
23
pane = win.get_data("pane")
24
do_events_with_sleep()
31
25
pane.on_search_terms_changed(None, "ark,artha,software-center")
26
do_events_with_sleep()
33
27
model = pane.app_view.tree_view.get_model()
35
29
# custom list should return three items
36
30
self.assertTrue(len(model) == 3)
38
32
# check package names, ordering is default "by relevance"
39
33
self.assertPkgInListAtIndex(0, model, "ark")
40
34
self.assertPkgInListAtIndex(1, model, "software-center")
41
35
self.assertPkgInListAtIndex(2, model, "artha")
43
37
# check that the status bar offers to install the packages
44
38
install_button = pane.action_bar.get_button(ActionButtons.INSTALL)
45
39
self.assertNotEqual(install_button, None)
47
GObject.timeout_add(TIMEOUT, lambda: win.destroy())
53
while Gtk.events_pending():
57
42
if __name__ == "__main__":
59
logging.basicConfig(level=logging.INFO)