~mvo/ubuntu-sso-client/strawman-lp711413

« back to all changes in this revision

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

  • Committer: Tarmac
  • Author(s): Manuel de la Pena, ralsina, Roberto Alsina
  • Date: 2011-04-14 17:01:56 UTC
  • mfrom: (705.2.2 forgotten_password)
  • Revision ID: tarmac-20110414170156-4k8s1708gzgj5oi2
Fixes lp:753281

Adds the required UI and backend to allow a windows user to reset his sso password from the Windows client. Tests have been added to ensure that the backend is correctly called.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from unittest import TestCase
20
20
from mocker import MATCH, Mocker
 
21
from PyQt4.QtCore import Qt
21
22
 
22
23
from ubuntu_sso.qt.gui import (
23
24
    ChooseSignInPage,
80
81
        self.widget.next = next_id
81
82
        self.assertEqual(next_id, self.widget.nextId())
82
83
 
 
84
    def test_existing_account_button(self):
 
85
        """Test the property."""
 
86
        self.assertEqual(self.ui.existing_account_button,
 
87
                         self.widget.existing_account_button)
 
88
 
 
89
    def test_new_account_button(self):
 
90
        """Test the property."""
 
91
        self.assertEqual(self.ui.setup_account_button,
 
92
                         self.widget.new_account_button)
 
93
 
83
94
 
84
95
class CurrentUserSignInPageTestCase(TestCase):
85
96
    """Test the CurrentUserSignInPage."""
102
113
        mocker.replay()
103
114
        self.widget = ChooseSignInPage(self.ui, self.controller)
104
115
 
 
116
    def test_email(self):
 
117
        """Test the email property."""
 
118
        # set the email in the ui and test that the result is the expected one
 
119
        email = 'manuel@canonical.com'
 
120
        self.ui.email_edit.setText(email)
 
121
        self.assertEqual(email, self.widget.email)
 
122
 
 
123
    def test_email_edit(self):
 
124
        """Test the email edit property."""
 
125
        self.assertEqual(self.ui.email_edit, self.widget.email_edit)
 
126
 
 
127
    def test_password(self):
 
128
        """Test the password property."""
 
129
        # set password in the ui and test that the result is the correct one
 
130
        password = 'password'
 
131
        self.ui.password_edit.setText(password)
 
132
        self.assertEqual(password, self.widget.password)
 
133
 
 
134
    def test_password_edit(self):
 
135
        """Test the password edit property."""
 
136
        self.assertEqual(self.ui.password_edit, self.widget.password_edit)
 
137
 
 
138
    def test_forgot_password_label(self):
 
139
        """Test the password forgto label."""
 
140
        self.assertEqual(self.ui.forgot_label,
 
141
                         self.widget.forgot_password_label)
 
142
 
 
143
    def test_signin_button(self):
 
144
        """Test the sign in button property."""
 
145
        self.assertEqual(self.ui.sign_in_button, self.widget.sign_in_button)
 
146
 
105
147
 
106
148
class EmailVerificationPageTestCase(TestCase):
107
149
    """Test the EmailVerificationPage."""
124
166
        mocker.replay()
125
167
        self.widget = EmailVerificationPage(self.ui, self.controller)
126
168
 
 
169
    def test_verification_code(self):
 
170
        """Test the verification code property."""
 
171
        verification = 'weird thing'
 
172
        self.ui.verification_code_edit.setText(verification)
 
173
        self.assertEqual(verification, self.widget.verification_code)
 
174
 
 
175
    def test_verification_code_edit(self):
 
176
        """Test the vericiation code edit property."""
 
177
        self.assertEqual(self.ui.verification_code_edit,
 
178
                         self.widget.verification_code_edit)
 
179
 
 
180
    def test_next_button(self):
 
181
        """Test the next button property."""
 
182
        self.assertEqual(self.ui.next_button, self.widget.next_button)
 
183
 
127
184
 
128
185
class TosPageTestCase(TestCase):
129
186
    """Test the TosPage."""
149
206
        """Test the nextId method."""
150
207
        self.assertEqual(-1, self.widget.nextId())
151
208
 
 
209
    def test_webkit(self):
 
210
        """Test the webkit property."""
 
211
        self.assertEqual(self.ui.terms_webkit, self.widget.webkit)
 
212
 
152
213
 
153
214
class SetUpAccountPageTestCase(TestCase):
154
215
    """Test the SetUpAccountPage."""
176
237
        self.widget.next = next_id
177
238
        self.assertEqual(next_id, self.widget.nextId())
178
239
 
 
240
    def test_set_line_edit_validation_rule(self):
 
241
        """Test the method that sets the validation runles."""
 
242
 
 
243
    def test_name(self):
 
244
        """Test the property that returns the name."""
 
245
        name = 'Manuel'
 
246
        self.ui.first_name_edit.setText(name)
 
247
        self.assertEqual(name, self.widget.name)
 
248
 
 
249
    def test_name_edit(self):
 
250
        """Test the property that returns the name edit."""
 
251
        self.assertEqual(self.ui.first_name_edit, self.widget.name_edit)
 
252
 
 
253
    def test_last_name(self):
 
254
        """Test the property that returns the last name."""
 
255
        last_name = 'de la Pena'
 
256
        self.ui.last_name_edit.setText(last_name)
 
257
        self.assertEqual(last_name, self.widget.last_name)
 
258
 
 
259
    def test_last_name_edit(self):
 
260
        """Test the property that returns the last name edit."""
 
261
        self.assertEqual(self.ui.last_name_edit, self.widget.last_name_edit)
 
262
 
 
263
    def test_email(self):
 
264
        """Test the property that returns the email."""
 
265
        email = 'manuel@canonical.com'
 
266
        self.ui.email_edit.setText(email)
 
267
        self.assertEqual(email, self.widget.email)
 
268
 
 
269
    def test_email_edit(self):
 
270
        """Test the property that returns the email edit."""
 
271
        self.assertEqual(self.ui.email_edit, self.widget.email_edit)
 
272
 
 
273
    def test_retyped_email(self):
 
274
        """Test the property that returns the re-typed email."""
 
275
        retyped_email = 'manuel@canonical.com'
 
276
        self.ui.confirm_email_edit.setText(retyped_email)
 
277
        self.assertEqual(retyped_email, self.widget.retyped_email)
 
278
 
 
279
    def test_confirm_email_edit(self):
 
280
        """Test the property that returns the confirm edit."""
 
281
        self.assertEqual(self.ui.confirm_email_edit,
 
282
                         self.widget.confirm_email_edit)
 
283
 
 
284
    def test_password_info_label(self):
 
285
        """Test the property that returns the password info label."""
 
286
        self.assertEqual(self.ui.password_info_label,
 
287
            self.widget.password_info_label)
 
288
 
 
289
    def test_pasword(self):
 
290
        """Test the property that returns the password."""
 
291
        password = 'password'
 
292
        self.ui.password_edit.setText(password)
 
293
        self.assertEqual(password, self.widget.password)
 
294
 
 
295
    def test_password_edit(self):
 
296
        """Test the property that returns the password edit."""
 
297
        self.assertEqual(self.ui.password_edit, self.widget.password_edit)
 
298
 
 
299
    def test_retyped_password(self):
 
300
        """Test the property that returns the retyped password."""
 
301
        password = 'password'
 
302
        self.ui.confirm_password_edit.setText(password)
 
303
        self.assertEqual(password, self.widget.retyped_password)
 
304
 
 
305
    def test_confirm_password_edit(self):
 
306
        """Test the property that returns the password confirm edit."""
 
307
        self.assertEqual(self.ui.confirm_password_edit,
 
308
                         self.widget.confirm_password_edit)
 
309
 
 
310
    def test_captcha_refresh_label(self):
 
311
        """Test the property that returns the captcha refresh label."""
 
312
        self.assertEqual(self.ui.refresh_label,
 
313
                         self.widget.captcha_refresh_label)
 
314
 
 
315
    def test_captcha_solution(self):
 
316
        """Test the property that returns the capthca solution."""
 
317
        solution = 'solution'
 
318
        self.ui.captcha_solution_edit.setText(solution)
 
319
        self.assertEqual(solution, self.widget.captcha_solution)
 
320
 
 
321
    def test_tos_agreed_false(self):
 
322
        """Test the property that returns if the tos was agreed."""
 
323
        self.ui.terms_checkbox.setCheckState(Qt.Unchecked)
 
324
        self.assertFalse(self.widget.terms_and_conditions_agreed)
 
325
 
 
326
    def test_tos_agreed_true(self):
 
327
        """Test the property that returns if the tos was agreed."""
 
328
        # check the box and test that the result is the expected one
 
329
        self.ui.terms_checkbox.setCheckState(Qt.Checked)
 
330
        self.assertTrue(self.widget.terms_and_conditions_agreed)
 
331
 
 
332
    def test_tos_button(self):
 
333
        """Test the property that returns the tos button."""
 
334
        self.assertEqual(self.ui.terms_button,
 
335
                         self.widget.terms_and_conditions_button)
 
336
 
 
337
    def test_set_up_button(self):
 
338
        """Test the property that returns the set up button."""
 
339
        self.assertEqual(self.ui.set_up_button, self.widget.set_up_button)
 
340
 
179
341
 
180
342
class SuccessPageTestCase(TestCase):
181
343
    """Test that the correct widgets are used."""
197
359
        mocker.replay()
198
360
        self.widget = SuccessPage(self.ui, self.controller)
199
361
 
 
362
    def test_success_message_label(self):
 
363
        """Test that the correct label is returned."""
 
364
        self.assertEqual(self.ui.success_message_label,
 
365
                         self.widget.success_message_label)
 
366
 
200
367
 
201
368
class ErrorPageTestCase(TestCase):
202
369
    """Test that the correct widgets are used."""
217
384
        controller.setupUi(MATCH(lambda x: isinstance(x, ErrorPage)))
218
385
        mocker.replay()
219
386
        self.widget = ErrorPage(self.ui, self.controller)
 
387
 
 
388
    def test_success_message_label(self):
 
389
        """Test that the correct label is returned."""
 
390
        self.assertEqual(self.ui.error_message_label,
 
391
                         self.widget.error_message_label)