~xubuntu-dev/ubiquity/lp1437180_feh

« back to all changes in this revision

Viewing changes to tests/test_migrationassistant.py

  • Committer: Colin Watson
  • Date: 2012-04-30 23:38:41 UTC
  • mfrom: (5402 trunk)
  • mto: This revision was merged to the branch mainline in revision 5403.
  • Revision ID: cjwatson@canonical.com-20120430233841-xb0qsk46lnhski7m
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/python
 
2
 
 
3
import os
 
4
import unittest
 
5
 
 
6
import mock
 
7
 
 
8
class TestMigrationAssistant(unittest.TestCase):
 
9
    def setUp(self):
 
10
        os.environ['UBIQUITY_MIGRATION_ASSISTANT'] = '1'
 
11
 
 
12
    def tearDown(self):
 
13
        del os.environ['UBIQUITY_MIGRATION_ASSISTANT']
 
14
 
 
15
    @mock.patch('ubiquity.misc.execute')
 
16
    @mock.patch('ubiquity.misc.execute_root')
 
17
    @mock.patch('ubiquity.misc.dmimodel')
 
18
    @mock.patch('ubiquity.misc.drop_privileges')
 
19
    @mock.patch('ubiquity.misc.regain_privileges')
 
20
    @mock.patch('ubiquity.frontend.gtk_ui.Wizard.customize_installer')
 
21
    @mock.patch('ubiquity.nm.wireless_hardware_present')
 
22
    @mock.patch('ubiquity.nm.NetworkManager.start')
 
23
    @mock.patch('ubiquity.nm.NetworkManager.get_state')
 
24
    @mock.patch('ubiquity.misc.has_connection')
 
25
    @mock.patch('ubiquity.upower.setup_power_watch')
 
26
    @mock.patch('dbus.mainloop.glib.DBusGMainLoop')
 
27
    @mock.patch('gi.repository.UbiquityWebcam.Webcam.available')
 
28
    @mock.patch('ubiquity.i18n.reset_locale')
 
29
    def test_sensible_treeview_size(self, mock_reset_locale, *args):
 
30
        """The tree view should show at least a sensible number of items."""
 
31
        from ubiquity.frontend import gtk_ui
 
32
        mock_reset_locale.return_value = 'en_US.UTF-8'
 
33
        ui = gtk_ui.Wizard('test-ubiquity')
 
34
        ui.translate_pages()
 
35
        ma_page = [page for page in ui.pages
 
36
                   if page.module.NAME == 'migrationassistant'][0]
 
37
        ui.set_page(ma_page.module.NAME)
 
38
        tree = []
 
39
        for part in ('sda1', 'sda2', 'sda3', 'sda4'):
 
40
            tree.append({
 
41
                'user': 'tester',
 
42
                'part': part,
 
43
                'os': 'Ubuntu',
 
44
                'items': ['Bookmarks', 'Documents'],
 
45
                'selected': False,
 
46
                })
 
47
        ma_page.ui.ma_set_choices(tree)
 
48
        ui.refresh()
 
49
        visible_range = ui.matreeview.get_visible_range()
 
50
        if len(visible_range) == 3:  # pygobject < 3.1.92
 
51
            valid, start_path, end_path = visible_range
 
52
            self.assertTrue(valid)
 
53
        else:
 
54
            start_path, end_path = visible_range
 
55
        self.assertEqual('0', start_path.to_string())
 
56
        self.assertEqual('3', end_path.to_string())