19
18
from unittest import TestCase
20
19
from mocker import MATCH, Mocker
22
from ubuntu_sso.qt.gui import (
24
CurrentUserSignInPage,
25
EmailVerificationPage,
21
from PyQt4 import QtGui
23
from ubuntu_sso.qt.error_page import ErrorPage
24
from ubuntu_sso.qt.sign_in_page import SignInPage
25
from ubuntu_sso.qt.success_page import SuccessPage
27
from ubuntu_sso.qt.gui import Header
30
28
from ubuntu_sso.qt.ui.choose_sign_in_ui import Ui_ChooseSignInPage
31
from ubuntu_sso.qt.ui.current_user_sign_in_ui import Ui_CurrentUserSignInPage
32
from ubuntu_sso.qt.ui.email_verification_ui import Ui_EmailVerificationPage
33
29
from ubuntu_sso.qt.ui.error_message_ui import Ui_ErrorPage
34
from ubuntu_sso.qt.ui.setup_account_ui import Ui_SetUpAccountPage
35
30
from ubuntu_sso.qt.ui.success_message_ui import Ui_SuccessPage
62
57
# used a mocked ui for this
65
controller = mocker.mock()
66
ui.setupUi(MATCH(lambda x: isinstance(x, ChooseSignInPage)))
67
controller.setupUi(MATCH(lambda x: isinstance(x, ChooseSignInPage)))
60
ui.setupUi(MATCH(lambda x: isinstance(x, SignInPage)))
69
self.widget = ChooseSignInPage(self.ui, self.controller)
62
self.widget = SignInPage(self.ui, QtGui.QPixmap())
71
64
def test_next_id(self):
72
65
"""Test the nextId method."""
75
68
self.assertEqual(next_id, self.widget.nextId())
78
class CurrentUserSignInPageTestCase(TestCase):
79
"""Test the CurrentUserSignInPage."""
82
"""Set up the tests."""
83
super(CurrentUserSignInPageTestCase, self).setUp()
84
self.ui = Ui_CurrentUserSignInPage()
85
self.controller = FakeController()
86
self.widget = CurrentUserSignInPage(self.ui, self.controller)
88
def test_constructor(self):
89
"""Test the constructor of the class."""
92
controller = mocker.mock()
93
ui.setupUi(MATCH(lambda x: isinstance(x, CurrentUserSignInPage)))
94
controller.setupUi(MATCH(lambda x: isinstance(x,
95
CurrentUserSignInPage)))
97
self.widget = ChooseSignInPage(self.ui, self.controller)
100
class EmailVerificationPageTestCase(TestCase):
101
"""Test the EmailVerificationPage."""
104
"""Set up the tests."""
105
super(EmailVerificationPageTestCase, self).setUp()
106
self.ui = Ui_EmailVerificationPage()
107
self.controller = FakeController()
108
self.widget = EmailVerificationPage(self.ui, self.controller)
110
def test_constructor(self):
111
"""Test the constructor of the class."""
114
controller = mocker.mock()
115
ui.setupUi(MATCH(lambda x: isinstance(x, EmailVerificationPage)))
116
controller.setupUi(MATCH(lambda x: isinstance(x,
117
EmailVerificationPage)))
119
self.widget = EmailVerificationPage(self.ui, self.controller)
122
class SetUpAccountPageTestCase(TestCase):
123
"""Test the SetUpAccountPage."""
126
"""Set up the tests."""
127
super(SetUpAccountPageTestCase, self).setUp()
128
self.ui = Ui_SetUpAccountPage()
129
self.controller = FakeController()
130
self.widget = SetupAccountPage(self.ui, self.controller)
132
def test_constructor(self):
133
"""Test the constrcutor of the class."""
136
controller = mocker.mock()
137
ui.setupUi(MATCH(lambda x: isinstance(x, SetupAccountPage)))
138
controller.setupUi(MATCH(lambda x: isinstance(x, SetupAccountPage)))
140
self.widget = SetupAccountPage(self.ui, self.controller)
142
def test_next_id(self):
143
"""Test the newxtId method."""
145
self.widget.next = next_id
146
self.assertEqual(next_id, self.widget.nextId())
149
71
class SuccessPageTestCase(TestCase):
150
72
"""Test that the correct widgets are used."""