Merge lp:~diegosarmentero/ubuntu-sso-client/fix805460 into lp:ubuntu-sso-client

Proposed by Diego Sarmentero
Status: Merged
Approved by: Roberto Alsina
Approved revision: 748
Merged at revision: 748
Proposed branch: lp:~diegosarmentero/ubuntu-sso-client/fix805460
Merge into: lp:ubuntu-sso-client
Diff against target: 74 lines (+36/-3)
2 files modified
ubuntu_sso/qt/controllers.py (+12/-2)
ubuntu_sso/qt/tests/test_windows.py (+24/-1)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntu-sso-client/fix805460
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Review via email: mp+69716@code.launchpad.net

Commit message

Adding message box when the email is not valid.

Description of the change

Adding message box when the email is not valid.

To post a comment you must log in.
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :

Voting does not meet specified criteria. Required: Approve >= 1, Disapprove == 0, Needs Fixing == 0, Needs Information == 0, Resubmit == 0, Pending == 0. Got: 1 Pending.

Revision history for this message
Roberto Alsina (ralsina) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/qt/controllers.py'
2--- ubuntu_sso/qt/controllers.py 2011-07-27 19:20:57 +0000
3+++ ubuntu_sso/qt/controllers.py 2011-07-28 20:41:44 +0000
4@@ -482,6 +482,13 @@
5 class EmailVerificationController(BackendController):
6 """Controller used for the verification page."""
7
8+ def __init__(self, message_box=None):
9+ """Create a new instance."""
10+ super(EmailVerificationController, self).__init__()
11+ if message_box is None:
12+ message_box = QMessageBox
13+ self.message_box = message_box
14+
15 def _set_translated_strings(self):
16 """Set the trnaslated strings."""
17 logger.debug('EmailVerificationController._set_translated_strings')
18@@ -540,9 +547,12 @@
19 email = self.view.wizard().field('email_address').toString()
20 self.view.wizard().registrationSuccess.emit(app_name, email)
21
22- def on_email_validation_error(self, app_name, raised_error):
23+ def on_email_validation_error(self, app_name, error):
24 """Signal thrown when there's a problem validating the email."""
25- pass
26+ msg = error.get('email_token')
27+ if msg is None:
28+ msg = '\n'.join([v for _, v in sorted(error.iteritems())])
29+ self.message_box.critical(self.view, app_name, msg)
30
31 #pylint: disable=C0103
32 def pageInitialized(self):
33
34=== modified file 'ubuntu_sso/qt/tests/test_windows.py'
35--- ubuntu_sso/qt/tests/test_windows.py 2011-07-06 16:39:03 +0000
36+++ ubuntu_sso/qt/tests/test_windows.py 2011-07-28 20:41:44 +0000
37@@ -499,7 +499,8 @@
38 super(EmailVerificationControllerTestCase, self).setUp()
39 self.view = self.mocker.mock()
40 self.backend = self.mocker.mock()
41- self.controller = EmailVerificationController()
42+ self.controller = EmailVerificationController(
43+ message_box=self.mocker.mock())
44 self.controller.view = self.view
45 self.controller.backend = self.backend
46
47@@ -550,6 +551,28 @@
48 self.controller.validate_email()
49
50
51+class EmailVerificationControllerTestCase2(TestCase):
52+ """Tests for EmailVerificationController, but without Mocker"""
53+
54+ def setUp(self):
55+ super(EmailVerificationControllerTestCase2, self).setUp()
56+ self.message_box = FakeMessageBox()
57+ self.controller = EmailVerificationController(
58+ message_box=self.message_box)
59+ self.patch(self.controller, 'view', FakeView())
60+ self._called = False
61+
62+ def test_on_email_validation_error(self):
63+ """Test that on_email_validation_error callback works as expected."""
64+ error = dict(errtype='BadTokenError')
65+ app_name = 'app_name'
66+ self.controller.on_email_validation_error(app_name, error)
67+ self.assertEqual(self.message_box.critical_args, ((
68+ self.controller.view,
69+ app_name,
70+ 'BadTokenError'), {}))
71+
72+
73 class ErrorControllerTestCase(MockerTestCase):
74 """Test the success page controller."""
75

Subscribers

People subscribed via source and target branches