3
from gi.repository import Gtk, GObject
8
sys.path.insert(0,"../..")
9
sys.path.insert(0,"..")
11
from softwarecenter.enums import XapianValues, ActionButtons
12
import softwarecenter.paths
13
softwarecenter.paths.datadir = "../data"
17
class TestCustomLists(unittest.TestCase):
19
def _debug(self, index, model, needle):
20
print ("Expected '%s' at index '%s', " +
21
"and custom list contained: '%s'") % (
22
needle, index, model[index][0].get_value(XapianValues.PKGNAME))
24
def assertPkgInListAtIndex(self, index, model, needle):
26
self.assertEqual(doc.get_value(XapianValues.PKGNAME),
27
needle, self._debug(index, model, needle))
29
def test_custom_lists(self):
30
from softwarecenter.ui.gtk3.panes.availablepane import get_test_window
31
win = get_test_window()
32
pane = win.get_data("pane")
34
pane.on_search_terms_changed(None, "ark,artha,software-center")
36
model = pane.app_view.tree_view.get_model()
38
# custom list should return three items
39
self.assertTrue(len(model) == 3)
41
# check package names, ordering is default "by relevance"
42
self.assertPkgInListAtIndex(0, model, "ark")
43
self.assertPkgInListAtIndex(1, model, "software-center")
44
self.assertPkgInListAtIndex(2, model, "artha")
46
# check that the status bar offers to install the packages
47
install_button = pane.action_bar.get_button(ActionButtons.INSTALL)
48
self.assertNotEqual(install_button, None)
50
GObject.timeout_add(TIMEOUT, lambda: win.destroy())
56
while Gtk.events_pending():
60
if __name__ == "__main__":
62
logging.basicConfig(level=logging.INFO)