~mvo/software-center/new-apps-icons

« back to all changes in this revision

Viewing changes to test/test_search_per_spec.py

  • Committer: Michael Vogt
  • Date: 2010-07-30 22:03:17 UTC
  • Revision ID: michael.vogt@ubuntu.com-20100730220317-tjbur5q1mn7l1jfo
test/test_search_per_spec.py: add experimental code that performs the searches from the spec, but probably also useful for non-ldtp tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import apt
 
4
import gtk
 
5
import logging
 
6
import sys
 
7
import time
 
8
import unittest
 
9
 
 
10
sys.path.insert(0, "..")
 
11
 
 
12
from softwarecenter.app import SoftwareCenterApp
 
13
from softwarecenter.enums import XAPIAN_BASE_PATH
 
14
from softwarecenter.view.appview import AppStore
 
15
 
 
16
# see https://wiki.ubuntu.com/SoftwareCenter/SearchTesting
 
17
 
 
18
class SCGUITest(unittest.TestCase):
 
19
    
 
20
    def _p(self):
 
21
        while gtk.events_pending():
 
22
            gtk.main_iteration()
 
23
 
 
24
    def setUp(self):
 
25
        apt.apt_pkg.config.set("Dir::log::history", "/tmp")
 
26
        apt.apt_pkg.config.set("Dir::state::lists", "/tmp")
 
27
        self.app = SoftwareCenterApp("../data", XAPIAN_BASE_PATH)
 
28
        self.app.window_main.show_all()
 
29
        print "foo0"
 
30
        self._p()
 
31
        print "foo1"
 
32
 
 
33
    def _run_search(self, search_text):
 
34
        logging.info("_run_search", search_text)
 
35
        self.app.available_pane.searchentry.delete_text(0, -1)
 
36
        self.app.available_pane.searchentry.insert_text(search_text)
 
37
        self._p()
 
38
        time.sleep(1)
 
39
        self._p()
 
40
        return self.app.available_pane.app_view.get_model()
 
41
        
 
42
    def _debug(self, model, needle):
 
43
        print "Excpected '%s' first, but search results in model: " % needle
 
44
        for it in model:
 
45
            print " %s" % it[AppStore.COL_PKGNAME]
 
46
 
 
47
    def assertFirstPkgInModel(self, model, needle):
 
48
        #self.assertEqual(model[0][AppStore.COL_PKGNAME], 
 
49
        #                 needle, self._debug(model, needle))
 
50
        self._debug(model, needle)
 
51
 
 
52
    def test_search_per_spec(self):
 
53
        # assert we find the right package
 
54
        model = self._run_search("bzr-gtk")
 
55
        self.assertFirstPkgInModel(model, "bzr-gtk")
 
56
        # try dive into python
 
57
        model = self._run_search("dive into python")
 
58
        self.assertFirstPkgInModel(model, "diveintopython")
 
59
        # flash
 
60
        model = self._run_search("flash")
 
61
        self.assertFirstPkgInModel(model, "adobe-flashplugin")
 
62
        # genealogy
 
63
        model = self._run_search("genealogy")
 
64
        self.assertFirstPkgInModel(model, "gramps")
 
65
        # gnome-session
 
66
        model = self._run_search("gnome-session")
 
67
        self.assertFirstPkgInModel(model, "gnome-session")
 
68
        # linux-image
 
69
        model = self._run_search("linux-image")
 
70
        self.assertFirstPkgInModel(model, "linux-image")
 
71
        # mythtv
 
72
        model = self._run_search("mythtv")
 
73
        self.assertFirstPkgInModel(model, "mythtv")
 
74
        # openoffice
 
75
        model = self._run_search("openoffice")
 
76
        self.assertFirstPkgInModel(model, "openoffice.org")
 
77
        # pinball
 
78
        model = self._run_search("pinball")
 
79
        self.assertFirstPkgInModel(model, "pinball")
 
80
 
 
81
if __name__ == "__main__":
 
82
    unittest.main()