summaryrefslogtreecommitdiff
path: root/src/leap/gui/tests/test_firstrun_providerselect.py
blob: be7cc9c125101d08aca99e450a96ecbd71e9d21d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import sys
import unittest

import mock

from leap.testing import qunittest
from leap.testing import pyqt

from PyQt4 import QtGui
#from PyQt4 import QtCore
import PyQt4.QtCore  # some weirdness with mock module

from PyQt4.QtTest import QTest
#from PyQt4.QtCore import Qt

from leap.gui import firstrun


class TestPage(firstrun.providerselect.SelectProviderPage):
    pass


class SelectProviderPageTestCase(qunittest.TestCase):

    # XXX can spy on signal connections

    def setUp(self):
        self.app = QtGui.QApplication(sys.argv)
        QtGui.qApp = self.app
        self.page = TestPage(None)
        self.page.wizard = mock.MagicMock()
        self.page.wizard().netchecker.return_value = True

    def tearDown(self):
        QtGui.qApp = None
        self.app = None
        self.page = None

    def test__do_checks(self):
        eq = self.assertEqual
        checks = [x for x in self.page._do_checks()]
        eq(len(checks), 5)
        labels = [str(x) for (x, y), z in checks]
        eq(labels, ['head_sentinel', 'checking domain name',
                    'checking https connection',
                    'fetching provider info', 'end_sentinel'])
        progress = [y for (x, y), z in checks]
        eq(progress, [0, 20, 40, 80, 100])

        # XXX now: execute the functions
        # with proper mocks (for checkers and so on)
        # and try to cover all the exceptions
        checkfuns = [z for (x, y), z in checks]
        #import ipdb;ipdb.set_trace() 

    def test_next_button_is_disabled(self):
        pass


if __name__ == "__main__":
    unittest.main()