Merge lp:~diegosarmentero/ubuntu-sso-client/message-critical into lp:ubuntu-sso-client

Proposed by Diego Sarmentero
Status: Merged
Approved by: Roberto Alsina
Approved revision: 780
Merged at revision: 780
Proposed branch: lp:~diegosarmentero/ubuntu-sso-client/message-critical
Merge into: lp:ubuntu-sso-client
Diff against target: 190 lines (+29/-23)
2 files modified
ubuntu_sso/qt/controllers.py (+13/-10)
ubuntu_sso/qt/tests/test_windows.py (+16/-13)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntu-sso-client/message-critical
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Review via email: mp+74462@code.launchpad.net

Commit message

Set the page where the critical message is going to be displayed.

Description of the change

Set the page where the critical message is going to be displayed.

To post a comment you must log in.
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Looks good!

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-08-30 12:48:19 +0000
3+++ ubuntu_sso/qt/controllers.py 2011-09-07 15:51:22 +0000
4@@ -240,7 +240,8 @@
5 # let the user know
6 logger.error('Got error when login %s, error: %s',
7 self.view.wizard().app_name, error)
8- self.message_box.critical(_build_general_error_message(error))
9+ self.message_box.critical(_build_general_error_message(error),
10+ self.view)
11
12 def on_logged_in(self, app_name, result):
13 """We managed to log in."""
14@@ -418,14 +419,15 @@
15 def on_captcha_generation_error(self, error):
16 """An error ocurred."""
17 logger.debug('SetUpAccountController.on_captcha_generation_error')
18- self.message_box.critical(CAPTCHA_LOAD_ERROR)
19+ self.message_box.critical(CAPTCHA_LOAD_ERROR, self.view)
20
21 def on_user_registration_error(self, app_name, error):
22 """Let the user know we could not register."""
23 logger.debug('SetUpAccountController.on_user_registration_error')
24 # errors are returned as a dict with the data we want to show.
25 self._refresh_captcha()
26- self.message_box.critical(_build_general_error_message(error))
27+ self.message_box.critical(_build_general_error_message(error),
28+ self.view)
29
30 def on_user_registered(self, app_name, result):
31 """Execute when the user did register."""
32@@ -442,18 +444,18 @@
33 confirm_password = unicode(self.view.ui.confirm_password_edit.text())
34 captcha_solution = unicode(self.view.ui.captcha_solution_edit.text())
35 if not is_correct_email(email):
36- self.message_box.critical(EMAIL_INVALID)
37+ self.message_box.critical(EMAIL_INVALID, self.view)
38 if email != confirm_email:
39- self.message_box.critical(EMAIL_MISMATCH)
40+ self.message_box.critical(EMAIL_MISMATCH, self.view)
41 return False
42 if not is_min_required_password(password):
43- self.message_box.critical(PASSWORD_TOO_WEAK)
44+ self.message_box.critical(PASSWORD_TOO_WEAK, self.view)
45 return False
46 if password != confirm_password:
47- self.message_box.critical(PASSWORD_MISMATCH)
48+ self.message_box.critical(PASSWORD_MISMATCH, self.view)
49 return False
50 if not captcha_solution:
51- self.message_box.critical(CAPTCHA_REQUIRED_ERROR)
52+ self.message_box.critical(CAPTCHA_REQUIRED_ERROR, self.view)
53 return False
54 return True
55
56@@ -582,7 +584,7 @@
57 msg = error.get('email_token')
58 if msg is None:
59 msg = _build_general_error_message(error)
60- self.message_box.critical(msg)
61+ self.message_box.critical(msg, self.view)
62
63 #pylint: disable=C0103
64 def pageInitialized(self):
65@@ -773,7 +775,8 @@
66 """Let the user know that there was an error."""
67 logger.error('Got error changing password for %s, error: %s',
68 self.view.wizard().app_name, error)
69- self.message_box.critical(_build_general_error_message(error))
70+ self.message_box.critical(_build_general_error_message(error),
71+ self.view)
72
73 def set_new_password(self):
74 """Request a new password to be set."""
75
76=== modified file 'ubuntu_sso/qt/tests/test_windows.py'
77--- ubuntu_sso/qt/tests/test_windows.py 2011-08-30 12:10:40 +0000
78+++ ubuntu_sso/qt/tests/test_windows.py 2011-09-07 15:51:22 +0000
79@@ -279,39 +279,41 @@
80 def test_error_message_key(self):
81 """Test that on_login_error reacts to errors with "error_message"."""
82 self.on_error_method({"error_message": "WORRY!"})
83- self.assertEqual(self.message_box.critical_args, (('WORRY!',), {}))
84+ self.assertEqual(self.message_box.critical_args, (('WORRY!',
85+ self.controller.view), {}))
86
87 def test_message_key(self):
88 """Test that on_login_error reacts to errors with "message"."""
89 self.on_error_method({"message": "WORRY!"})
90- self.assertEqual(self.message_box.critical_args, (('WORRY!',), {}))
91+ self.assertEqual(self.message_box.critical_args, (('WORRY!',
92+ self.controller.view), {}))
93
94 def test_broken_error(self):
95 """Test that on_login_error reacts to broken errors."""
96 self.on_error_method({"boo!": "WORRY!"})
97 self.assertEqual(self.message_box.critical_args,
98- (("Error: {'boo!': 'WORRY!'}",), {}))
99+ (("Error: {'boo!': 'WORRY!'}", self.controller.view), {}))
100
101 def test_all_and_message(self):
102 """Test that on_login_error reacts to broken errors."""
103 self.on_error_method(
104 {"message": "WORRY!", "__all__": "MORE!"})
105 self.assertEqual(self.message_box.critical_args,
106- (('MORE!\nWORRY!',), {}))
107+ (('MORE!\nWORRY!', self.controller.view), {}))
108
109 def test_all_and_error_message(self):
110 """Test that on_login_error reacts to broken errors."""
111 self.on_error_method(
112 {"error_message": "WORRY!", "__all__": "MORE!"})
113 self.assertEqual(self.message_box.critical_args,
114- (('MORE!\nWORRY!',), {}))
115+ (('MORE!\nWORRY!', self.controller.view), {}))
116
117 def test_only_all(self):
118 """Test that on_login_error reacts to broken errors."""
119 self.on_error_method(
120 {"__all__": "MORE!"})
121 self.assertEqual(self.message_box.critical_args,
122- (('MORE!',), {}))
123+ (('MORE!', self.controller.view), {}))
124
125
126 class EmailVerificationControllerErrorTestCase(
127@@ -552,7 +554,7 @@
128 self.mocker.result(password)
129 self.view.ui.captcha_solution_edit.text()
130 self.mocker.result(captcha_solution)
131- self.message_box.critical(EMAIL_MISMATCH)
132+ self.message_box.critical(EMAIL_MISMATCH, self.controller.view)
133 self.mocker.replay()
134 self.assertFalse(self.controller.validate_form())
135
136@@ -571,7 +573,7 @@
137 self.mocker.result(captcha_solution)
138 self.view.ui.confirm_password_edit.text()
139 self.mocker.result(weak_password)
140- self.message_box.critical(PASSWORD_TOO_WEAK)
141+ self.message_box.critical(PASSWORD_TOO_WEAK, self.controller.view)
142 self.mocker.replay()
143 self.assertFalse(self.controller.validate_form())
144
145@@ -590,7 +592,7 @@
146 self.mocker.result('other_password')
147 self.view.ui.captcha_solution_edit.text()
148 self.mocker.result(captcha_solution)
149- self.message_box.critical(PASSWORD_MISMATCH)
150+ self.message_box.critical(PASSWORD_MISMATCH, self.controller.view)
151 self.mocker.replay()
152 self.assertFalse(self.controller.validate_form())
153
154@@ -609,7 +611,7 @@
155 self.mocker.result(password)
156 self.view.ui.captcha_solution_edit.text()
157 self.mocker.result(captcha_solution)
158- self.message_box.critical(CAPTCHA_REQUIRED_ERROR)
159+ self.message_box.critical(CAPTCHA_REQUIRED_ERROR, self.controller.view)
160 self.mocker.replay()
161 self.assertFalse(self.controller.validate_form())
162
163@@ -691,7 +693,7 @@
164 self.controller.on_user_registration_error('TestApp',
165 {'__all__': "Error in All"})
166 self.assertEqual(self.message_box.critical_args, ((
167- "Error in All", ), {}))
168+ "Error in All", self.controller.view), {}))
169
170 def test_on_user_registration_all_fields(self):
171 """Pass all known error keys, plus unknown one."""
172@@ -702,7 +704,7 @@
173 'unknownfield': "Error in unknown",
174 })
175 self.assertEqual(self.message_box.critical_args, ((
176- "Error in All", ), {}))
177+ "Error in All", self.controller.view), {}))
178
179
180 class EmailVerificationControllerTestCase(MockerTestCase):
181@@ -785,7 +787,8 @@
182 app_name = 'app_name'
183 self.controller.on_email_validation_error(app_name, error)
184 self.assertEqual(self.message_box.critical_args,
185- (("Error: {'errtype': 'BadTokenError'}",), {}))
186+ (("Error: {'errtype': 'BadTokenError'}",
187+ self.controller.view), {}))
188
189
190 class ErrorControllerTestCase(MockerTestCase):

Subscribers

People subscribed via source and target branches