~nataliabidart/software-center/winged-migration

« back to all changes in this revision

Viewing changes to tests/qml/test_ui_qml_helpers.py

  • Committer: Natalia B. Bidart
  • Date: 2012-05-30 18:39:55 UTC
  • mto: This revision was merged to the branch mainline in revision 3030.
  • Revision ID: natalia.bidart@canonical.com-20120530183955-zbnjczayktmmg5tv
- Initial test cleanup:
  - Renamed test/ dir to tests/.
  - Isolated test code into tests/ directory, including moving all the
    get_test_window_foo from the gtk3 production modules to
    tests/gtk3/windows.py module.
  - Removed all the calls to Gtk.main() in gtk3 tests since that blocks the
    execution of the suite.
  - Pep8 and pyflakes fixes in the files already modified in this branch.
  - Minor bug fix in the softwarecenter/log.py module when trying to create a
    log dir with proper perms.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
 
3
1
from gi.repository import GObject
4
2
 
5
3
import random
10
8
# ensure we set the review backend to the fake one
11
9
os.environ["SOFTWARE_CENTER_IPSUM_REVIEWS"] = "1"
12
10
 
13
 
import sys
14
 
sys.path.insert(0,"../")
15
11
from softwarecenter.db.pkginfo import get_pkg_info
16
12
from softwarecenter.ui.qml.categoriesmodel import CategoriesModel
17
13
from softwarecenter.ui.qml.pkglist import PkgListModel
18
14
from softwarecenter.ui.qml.reviewslist import ReviewsListModel
19
15
 
 
16
 
20
17
class TestQMLHelpers(unittest.TestCase):
21
18
    """ tests the helper classes for the qml code """
22
19
 
39
36
            role = CAT_NAME_COLUMN
40
37
            names.add(model.data(index, role))
41
38
        self.assertTrue("Games" in names)
42
 
        
 
39
 
43
40
    def test_pkglist_model(self):
44
41
        APP_NAME_COLUMN = 0
45
42
        # get model
59
56
        # en_DK/en_US fun
60
57
        self.assertTrue("Ubuntu Software Center" in names or
61
58
                        "Ubuntu Software Centre" in names)
62
 
        # test setCategory by ensuring that setCategory() cuts the nr of 
 
59
        # test setCategory by ensuring that setCategory() cuts the nr of
63
60
        # search results
64
61
        old_search_hits =  model.rowCount()
65
62
        model.setCategory("Games")
104
101
        # ensure the signal got send
105
102
        self.assertTrue(self._i_am_refreshed)
106
103
        del self._i_am_refreshed
107
 
    
 
104
 
108
105
    def _p(self):
109
106
        context = GObject.main_context_default()
110
107
        while context.pending():
111
108
            context.iteration()
112
109
 
113
110
if __name__ == "__main__":
114
 
    import logging
115
 
    logging.basicConfig(level=logging.DEBUG)
116
111
    unittest.main()