~nataliabidart/ubuntu-sso-client/find-me-bin-dir

« back to all changes in this revision

Viewing changes to ubuntu_sso/qt/tests/test_qt_views.py

- Refactor the pages and controller in sso (LP: #929686).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- coding: utf-8 -*-
2
 
# Author: Manuel de la Pena <manuel@canonical.com>
3
2
#
4
3
# Copyright 2011 Canonical Ltd.
5
4
#
19
18
from unittest import TestCase
20
19
from mocker import MATCH, Mocker
21
20
 
22
 
from ubuntu_sso.qt.gui import (
23
 
    ChooseSignInPage,
24
 
    CurrentUserSignInPage,
25
 
    EmailVerificationPage,
26
 
    ErrorPage,
27
 
    Header,
28
 
    SetupAccountPage,
29
 
    SuccessPage)
 
21
from PyQt4 import QtGui
 
22
 
 
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
 
26
 
 
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
36
31
 
37
32
 
52
47
        super(ChooseSignInPageTestCase, self).setUp()
53
48
        self.ui = Ui_ChooseSignInPage()
54
49
        self.controller = FakeController()
55
 
        self.widget = ChooseSignInPage(self.ui, self.controller)
 
50
        self.widget = SignInPage(self.ui, QtGui.QPixmap())
56
51
 
57
52
    def tearDown(self):
58
53
        self.widget.close()
62
57
        # used a mocked ui for this
63
58
        mocker = Mocker()
64
59
        ui = mocker.mock()
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)))
68
61
        mocker.replay()
69
 
        self.widget = ChooseSignInPage(self.ui, self.controller)
 
62
        self.widget = SignInPage(self.ui, QtGui.QPixmap())
70
63
 
71
64
    def test_next_id(self):
72
65
        """Test the nextId method."""
75
68
        self.assertEqual(next_id, self.widget.nextId())
76
69
 
77
70
 
78
 
class CurrentUserSignInPageTestCase(TestCase):
79
 
    """Test the CurrentUserSignInPage."""
80
 
 
81
 
    def setUp(self):
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)
87
 
 
88
 
    def test_constructor(self):
89
 
        """Test the constructor of the class."""
90
 
        mocker = Mocker()
91
 
        ui = mocker.mock()
92
 
        controller = mocker.mock()
93
 
        ui.setupUi(MATCH(lambda x: isinstance(x, CurrentUserSignInPage)))
94
 
        controller.setupUi(MATCH(lambda x: isinstance(x,
95
 
                                                      CurrentUserSignInPage)))
96
 
        mocker.replay()
97
 
        self.widget = ChooseSignInPage(self.ui, self.controller)
98
 
 
99
 
 
100
 
class EmailVerificationPageTestCase(TestCase):
101
 
    """Test the EmailVerificationPage."""
102
 
 
103
 
    def setUp(self):
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)
109
 
 
110
 
    def test_constructor(self):
111
 
        """Test the constructor of the class."""
112
 
        mocker = Mocker()
113
 
        ui = mocker.mock()
114
 
        controller = mocker.mock()
115
 
        ui.setupUi(MATCH(lambda x: isinstance(x, EmailVerificationPage)))
116
 
        controller.setupUi(MATCH(lambda x: isinstance(x,
117
 
                                                      EmailVerificationPage)))
118
 
        mocker.replay()
119
 
        self.widget = EmailVerificationPage(self.ui, self.controller)
120
 
 
121
 
 
122
 
class SetUpAccountPageTestCase(TestCase):
123
 
    """Test the SetUpAccountPage."""
124
 
 
125
 
    def setUp(self):
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)
131
 
 
132
 
    def test_constructor(self):
133
 
        """Test the constrcutor of the class."""
134
 
        mocker = Mocker()
135
 
        ui = mocker.mock()
136
 
        controller = mocker.mock()
137
 
        ui.setupUi(MATCH(lambda x: isinstance(x, SetupAccountPage)))
138
 
        controller.setupUi(MATCH(lambda x: isinstance(x, SetupAccountPage)))
139
 
        mocker.replay()
140
 
        self.widget = SetupAccountPage(self.ui, self.controller)
141
 
 
142
 
    def test_next_id(self):
143
 
        """Test the newxtId method."""
144
 
        next_id = 1
145
 
        self.widget.next = next_id
146
 
        self.assertEqual(next_id, self.widget.nextId())
147
 
 
148
 
 
149
71
class SuccessPageTestCase(TestCase):
150
72
    """Test that the correct widgets are used."""
151
73