Merge lp:~diegosarmentero/ubuntuone-windows-installer/reset-password-page into lp:ubuntuone-windows-installer
- reset-password-page
- Merge into trunk
Proposed by
Diego Sarmentero
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Roberto Alsina | ||||
Approved revision: | 47 | ||||
Merged at revision: | 50 | ||||
Proposed branch: | lp:~diegosarmentero/ubuntuone-windows-installer/reset-password-page | ||||
Merge into: | lp:ubuntuone-windows-installer | ||||
Diff against target: |
402 lines (+29/-266) 2 files modified
ubuntuone_installer/gui/qt/setup_account.py (+18/-74) ubuntuone_installer/gui/qt/tests/test_setup_account.py (+11/-192) |
||||
To merge this branch: | bzr merge lp:~diegosarmentero/ubuntuone-windows-installer/reset-password-page | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Natalia Bidart (community) | Approve | ||
Review via email: mp+73523@code.launchpad.net |
Commit message
Reset Password Page Complete.
Description of the change
Reset Password Page Complete.
To post a comment you must log in.
- 46. By Diego Sarmentero
-
Changed utils.ui to common in setup_account and test_setup_account.
Merge.
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote : | # |
- 47. By Diego Sarmentero
-
Assigning bug.
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 'ubuntuone_installer/gui/qt/setup_account.py' |
2 | --- ubuntuone_installer/gui/qt/setup_account.py 2011-08-31 16:23:45 +0000 |
3 | +++ ubuntuone_installer/gui/qt/setup_account.py 2011-09-06 15:25:05 +0000 |
4 | @@ -23,6 +23,7 @@ |
5 | |
6 | from PyQt4 import QtGui, QtCore |
7 | |
8 | +from ubuntu_sso.qt import common |
9 | from ubuntu_sso.qt import gui as sso_gui |
10 | |
11 | from ubuntuone_installer.gui.qt import enhanced_check_box |
12 | @@ -30,10 +31,7 @@ |
13 | _ = gettext.gettext |
14 | |
15 | # pylint: disable=C0103 |
16 | -BAD = u'<img src=":/password_hint_warning.png" /><font> %s </font>' |
17 | ERROR = u'<font color="#df2d1f"><b> %s </b></font>' |
18 | -GOOD = u'<img src=":/password_hint_ok.png" /><font> %s </font>' |
19 | -NORMAL = u'<font> %s </font>' |
20 | TITLE_STYLE = "<span style=\"font-size:24px\">%s</span>" |
21 | |
22 | EMAIL = _("Email") |
23 | @@ -42,11 +40,6 @@ |
24 | EMAIL_MATCH = _("The email addresses do not match") |
25 | NAME = _("Name") |
26 | PASSWORD = _("Create a password") |
27 | -PASSWORD_LENGTH = _("At least 8 characters") |
28 | -PASSWORD_DIGIT = _("At least one number") |
29 | -PASSWORD_UPPER = _("At least one uppercase letter") |
30 | -PASSWORD_MATCH = _("Passwords don't match") |
31 | -PASSWORD_MUST_CONTAIN = _("Your password must contain") |
32 | RETYPE_EMAIL = _("Retype email") |
33 | RETYPE_PASSWORD = _("Retype password") |
34 | SUBTITLE = _("You only need to set up your account " |
35 | @@ -67,7 +60,9 @@ |
36 | def __init__(self, *args, **kwargs): |
37 | super(SetupAccountPage, self).__init__(*args, **kwargs) |
38 | self.ui.password_edit.textEdited.connect( |
39 | - lambda: self.password_assistance(NORMAL)) |
40 | + lambda: common.password_assistance(self.ui.password_edit, |
41 | + self.ui.password_assistance, |
42 | + common.NORMAL)) |
43 | terms = TERMS.format(terms_and_conditions=TERMS_LINK, |
44 | privacy_policy=PRIVACY_POLICY_LINK) |
45 | self.terms_checkbox = enhanced_check_box.EnhancedCheckBox(terms) |
46 | @@ -78,9 +73,15 @@ |
47 | self.name_assistance, |
48 | self.email_assistance, |
49 | self.confirm_email_assistance, |
50 | - self.password_check_match] |
51 | + self.password_check_match_wrapper] |
52 | self.set_up_button = None |
53 | |
54 | + def password_check_match_wrapper(self): |
55 | + """Wrapper between validation_functions calls and utils function.""" |
56 | + common.password_check_match(self.ui.password_edit, |
57 | + self.ui.confirm_password_edit, |
58 | + self.ui.password_assistance) |
59 | + |
60 | # Invalid name "initializePage" |
61 | # pylint: disable=C0103 |
62 | |
63 | @@ -114,7 +115,7 @@ |
64 | QtGui.QWizard.Stretch, |
65 | QtGui.QWizard.CustomButton3]) |
66 | |
67 | - self.password_default_assistance() |
68 | + common.password_default_assistance(self.ui.password_assistance) |
69 | # Hide assistance labels by default |
70 | self.ui.name_assistance.setVisible(False) |
71 | self.ui.email_assistance.setVisible(False) |
72 | @@ -145,10 +146,10 @@ |
73 | if not text.strip(): |
74 | self.ui.name_assistance.setVisible(True) |
75 | self.ui.name_assistance.setText(ERROR % EMPTY_NAME) |
76 | - self.check_as_invalid(self.ui.name_edit) |
77 | + common.check_as_invalid(self.ui.name_edit) |
78 | else: |
79 | self.ui.name_assistance.setVisible(False) |
80 | - self.check_as_valid(self.ui.name_edit) |
81 | + common.check_as_valid(self.ui.name_edit) |
82 | |
83 | def email_assistance(self): |
84 | """Show help for the email field.""" |
85 | @@ -156,10 +157,10 @@ |
86 | if not is_correct_email(text): |
87 | self.ui.email_assistance.setText(ERROR % INVALID_EMAIL) |
88 | self.ui.email_assistance.setVisible(True) |
89 | - self.check_as_invalid(self.ui.email_edit) |
90 | + common.check_as_invalid(self.ui.email_edit) |
91 | else: |
92 | self.ui.email_assistance.setVisible(False) |
93 | - self.check_as_valid(self.ui.email_edit) |
94 | + common.check_as_valid(self.ui.email_edit) |
95 | |
96 | def confirm_email_assistance(self): |
97 | """Show help for the confirm email field.""" |
98 | @@ -168,67 +169,10 @@ |
99 | if text1 != text2: |
100 | self.ui.confirm_email_assistance.setText(ERROR % EMAIL_MATCH) |
101 | self.ui.confirm_email_assistance.setVisible(True) |
102 | - self.check_as_invalid(self.ui.confirm_email_edit) |
103 | + common.check_as_invalid(self.ui.confirm_email_edit) |
104 | else: |
105 | self.ui.confirm_email_assistance.setVisible(False) |
106 | - self.check_as_valid(self.ui.confirm_email_edit) |
107 | - |
108 | - def password_assistance(self, icon_type=BAD): |
109 | - """Show help for the password field.""" |
110 | - text1 = unicode(self.ui.password_edit.text()) |
111 | - label_text = ["<b>%s</b>" % PASSWORD_MUST_CONTAIN, ] |
112 | - |
113 | - if len(text1) < 8: |
114 | - sign = icon_type |
115 | - else: |
116 | - sign = GOOD |
117 | - label_text.append(sign % PASSWORD_LENGTH) |
118 | - |
119 | - if re.search('[A-Z]', text1) is None: |
120 | - sign = icon_type |
121 | - else: |
122 | - sign = GOOD |
123 | - label_text.append(sign % PASSWORD_UPPER) |
124 | - |
125 | - if re.search('[\d+]', text1) is None: |
126 | - sign = icon_type |
127 | - else: |
128 | - sign = GOOD |
129 | - label_text.append(sign % PASSWORD_DIGIT) |
130 | - |
131 | - self.ui.password_assistance.setText("<br>".join(label_text)) |
132 | - |
133 | - def password_check_match(self): |
134 | - """Check if passwords match, otherwise show a message.""" |
135 | - self.password_assistance() |
136 | - label_text = unicode(self.ui.password_assistance.text()) |
137 | - text1 = unicode(self.ui.password_edit.text()) |
138 | - text2 = unicode(self.ui.confirm_password_edit.text()) |
139 | - if text1 != text2: |
140 | - label_text += "<br>" + BAD % PASSWORD_MATCH |
141 | - self.ui.password_assistance.setText(label_text) |
142 | - |
143 | - def password_default_assistance(self): |
144 | - """Show default help for the password field.""" |
145 | - label_text = ["<b>%s</b>" % PASSWORD_MUST_CONTAIN, ] |
146 | - |
147 | - label_text.append(NORMAL % PASSWORD_LENGTH) |
148 | - label_text.append(NORMAL % PASSWORD_UPPER) |
149 | - label_text.append(NORMAL % PASSWORD_DIGIT) |
150 | - |
151 | - self.ui.password_assistance.setText("<br>".join(label_text)) |
152 | - |
153 | - def check_as_invalid(self, line_edit): |
154 | - """Set QLineEdit's formError property as True, refresh the style.""" |
155 | - line_edit.setProperty("formError", True) |
156 | - line_edit.style().unpolish(line_edit) |
157 | - line_edit.style().polish(line_edit) |
158 | - |
159 | - def check_as_valid(self, line_edit): |
160 | - """Set QLineEdit's formError property as False, refresh the style.""" |
161 | - line_edit.setProperty("formError", False) |
162 | - line_edit.style().unpolish(line_edit) |
163 | - line_edit.style().polish(line_edit) |
164 | + common.check_as_valid(self.ui.confirm_email_edit) |
165 | |
166 | def showEvent(self, event): |
167 | """Set set_up_button as default button when the page is shown.""" |
168 | |
169 | === modified file 'ubuntuone_installer/gui/qt/tests/test_setup_account.py' |
170 | --- ubuntuone_installer/gui/qt/tests/test_setup_account.py 2011-08-30 16:09:00 +0000 |
171 | +++ ubuntuone_installer/gui/qt/tests/test_setup_account.py 2011-09-06 15:25:05 +0000 |
172 | @@ -22,6 +22,8 @@ |
173 | |
174 | from PyQt4 import QtGui, QtCore |
175 | |
176 | +from ubuntu_sso.qt import common |
177 | + |
178 | from ubuntuone_installer.gui.qt import gui, setup_account |
179 | from ubuntuone_installer.gui.qt.tests import BaseTestCase |
180 | from ubuntuone_installer.gui.qt.ui import ( |
181 | @@ -135,103 +137,6 @@ |
182 | setup_account.ERROR % setup_account.EMPTY_NAME) |
183 | self.ui.hide() |
184 | |
185 | - def test_short_password(self): |
186 | - """Status with short password. |
187 | - |
188 | - * Password assistance contains the right message. |
189 | - """ |
190 | - self.ui.ui.password_edit.setText("foobar") |
191 | - self.ui.password_assistance() |
192 | - self.assertIn( |
193 | - setup_account.BAD % setup_account.PASSWORD_LENGTH, |
194 | - unicode(self.ui.ui.password_assistance.text()), |
195 | - ) |
196 | - |
197 | - def test_long_password(self): |
198 | - """Status with long password. |
199 | - |
200 | - * Password assistance contains the right message. |
201 | - """ |
202 | - self.ui.ui.password_edit.setText("foobarbaz") |
203 | - self.ui.password_assistance() |
204 | - self.assertIn( |
205 | - setup_account.GOOD % setup_account.PASSWORD_LENGTH, |
206 | - unicode(self.ui.ui.password_assistance.text()), |
207 | - ) |
208 | - |
209 | - def test_no_number_password(self): |
210 | - """Status with password without a number. |
211 | - |
212 | - * Password assistance contains the right message. |
213 | - """ |
214 | - self.ui.ui.password_edit.setText("foobarbaz") |
215 | - self.ui.password_assistance() |
216 | - self.assertIn( |
217 | - setup_account.BAD % setup_account.PASSWORD_DIGIT, |
218 | - unicode(self.ui.ui.password_assistance.text()), |
219 | - ) |
220 | - |
221 | - def test_number_password(self): |
222 | - """Status with password with a number. |
223 | - |
224 | - * Password assistance contains the right message. |
225 | - """ |
226 | - self.ui.ui.password_edit.setText("foobarba7") |
227 | - self.ui.password_assistance() |
228 | - self.assertIn( |
229 | - setup_account.GOOD % setup_account.PASSWORD_DIGIT, |
230 | - unicode(self.ui.ui.password_assistance.text()), |
231 | - ) |
232 | - |
233 | - def test_no_uppercase_password(self): |
234 | - """Status with password without uppercase letters. |
235 | - |
236 | - * Password assistance contains the right message. |
237 | - """ |
238 | - self.ui.ui.password_edit.setText("foobarbaz") |
239 | - self.ui.password_assistance() |
240 | - self.assertIn( |
241 | - setup_account.BAD % setup_account.PASSWORD_UPPER, |
242 | - unicode(self.ui.ui.password_assistance.text()), |
243 | - ) |
244 | - |
245 | - def test_upper_password(self): |
246 | - """Status with password with uppercase letters. |
247 | - |
248 | - * Password assistance contains the right message. |
249 | - """ |
250 | - self.ui.ui.password_edit.setText("Foobarba7") |
251 | - self.ui.password_assistance() |
252 | - self.assertIn( |
253 | - setup_account.GOOD % setup_account.PASSWORD_UPPER, |
254 | - unicode(self.ui.ui.password_assistance.text()), |
255 | - ) |
256 | - |
257 | - def test_matching_passwords(self): |
258 | - """Status when the passwords match. |
259 | - |
260 | - * Password assistance doesn't contain the message. |
261 | - """ |
262 | - self.ui.ui.password_edit.setText("Foobarba7") |
263 | - self.ui.ui.confirm_password_edit.setText("Foobarba7") |
264 | - self.ui.password_check_match() |
265 | - self.assertNotIn( |
266 | - setup_account.BAD % setup_account.PASSWORD_MATCH, |
267 | - unicode(self.ui.ui.password_assistance.text())) |
268 | - |
269 | - def test_not_matching_passwords(self): |
270 | - """Status when the passwords not match. |
271 | - |
272 | - * Password assistance contains the right message. |
273 | - """ |
274 | - self.ui.ui.password_edit.setText("Foobarba7") |
275 | - self.ui.ui.confirm_password_edit.setText("BazBarFo0") |
276 | - self.ui.password_check_match() |
277 | - self.assertIn( |
278 | - setup_account.BAD % setup_account.PASSWORD_MATCH, |
279 | - unicode(self.ui.ui.password_assistance.text()), |
280 | - ) |
281 | - |
282 | def test_password_default_assistance(self): |
283 | """Status when the password line edit receive focus and shows popup. |
284 | |
285 | @@ -242,91 +147,15 @@ |
286 | self.ui.validate_data_on_focus_changed(4) |
287 | self.ui.focus_changed(None, self.ui.ui.password_edit) |
288 | self.assertIn( |
289 | - setup_account.NORMAL % setup_account.PASSWORD_LENGTH, |
290 | - unicode(self.ui.ui.password_assistance.text()), |
291 | - ) |
292 | - self.assertIn( |
293 | - setup_account.NORMAL % setup_account.PASSWORD_UPPER, |
294 | - unicode(self.ui.ui.password_assistance.text()), |
295 | - ) |
296 | - self.assertIn( |
297 | - setup_account.NORMAL % setup_account.PASSWORD_DIGIT, |
298 | - unicode(self.ui.ui.password_assistance.text()), |
299 | - ) |
300 | - |
301 | - def test_password_assistance_in_focus_length_correct(self): |
302 | - """Check the QLineEdit for password when the length is correct.""" |
303 | - self.ui.ui.password_edit.setText("aaaaaaaaa") |
304 | - self.ui.ui.confirm_password_edit.setText("") |
305 | - self.ui.password_assistance(setup_account.NORMAL) |
306 | - self.assertIn( |
307 | - setup_account.GOOD % setup_account.PASSWORD_LENGTH, |
308 | - unicode(self.ui.ui.password_assistance.text()), |
309 | - ) |
310 | - self.assertIn( |
311 | - setup_account.NORMAL % setup_account.PASSWORD_UPPER, |
312 | - unicode(self.ui.ui.password_assistance.text()), |
313 | - ) |
314 | - self.assertIn( |
315 | - setup_account.NORMAL % setup_account.PASSWORD_DIGIT, |
316 | - unicode(self.ui.ui.password_assistance.text()), |
317 | - ) |
318 | - |
319 | - def test_password_assistance_in_focus_with_upper(self): |
320 | - """Check the QLineEdit for password when it has an upper case char.""" |
321 | - self.ui.ui.password_edit.setText("AAa") |
322 | - self.ui.ui.confirm_password_edit.setText("") |
323 | - self.ui.password_assistance(setup_account.NORMAL) |
324 | - self.assertIn( |
325 | - setup_account.NORMAL % setup_account.PASSWORD_LENGTH, |
326 | - unicode(self.ui.ui.password_assistance.text()), |
327 | - ) |
328 | - self.assertIn( |
329 | - setup_account.GOOD % setup_account.PASSWORD_UPPER, |
330 | - unicode(self.ui.ui.password_assistance.text()), |
331 | - ) |
332 | - self.assertIn( |
333 | - setup_account.NORMAL % setup_account.PASSWORD_DIGIT, |
334 | - unicode(self.ui.ui.password_assistance.text()), |
335 | - ) |
336 | - |
337 | - def test_password_assistance_in_focus_with_number(self): |
338 | - """Check the QLineEdit for password when it contains numbers.""" |
339 | - self.ui.ui.password_edit.setText("a123") |
340 | - self.ui.ui.confirm_password_edit.setText("") |
341 | - self.ui.password_assistance(setup_account.NORMAL) |
342 | - self.assertIn( |
343 | - setup_account.NORMAL % setup_account.PASSWORD_LENGTH, |
344 | - unicode(self.ui.ui.password_assistance.text()), |
345 | - ) |
346 | - self.assertIn( |
347 | - setup_account.NORMAL % setup_account.PASSWORD_UPPER, |
348 | - unicode(self.ui.ui.password_assistance.text()), |
349 | - ) |
350 | - self.assertIn( |
351 | - setup_account.GOOD % setup_account.PASSWORD_DIGIT, |
352 | - unicode(self.ui.ui.password_assistance.text()), |
353 | - ) |
354 | - |
355 | - def test_password_assistance_in_focus_all_ok(self): |
356 | - """Check the QLineEdit for password when all the condition are ok.""" |
357 | - self.ui.ui.password_edit.setText("T3st3rqw") |
358 | - self.ui.ui.confirm_password_edit.setText("T3st3rqw") |
359 | - self.ui.password_assistance(setup_account.NORMAL) |
360 | - self.assertIn( |
361 | - setup_account.GOOD % setup_account.PASSWORD_LENGTH, |
362 | - unicode(self.ui.ui.password_assistance.text()), |
363 | - ) |
364 | - self.assertIn( |
365 | - setup_account.GOOD % setup_account.PASSWORD_UPPER, |
366 | - unicode(self.ui.ui.password_assistance.text()), |
367 | - ) |
368 | - self.assertIn( |
369 | - setup_account.GOOD % setup_account.PASSWORD_DIGIT, |
370 | - unicode(self.ui.ui.password_assistance.text()), |
371 | - ) |
372 | - self.assertNotIn( |
373 | - setup_account.NORMAL % setup_account.PASSWORD_MATCH, |
374 | + common.NORMAL % common.PASSWORD_LENGTH, |
375 | + unicode(self.ui.ui.password_assistance.text()), |
376 | + ) |
377 | + self.assertIn( |
378 | + common.NORMAL % common.PASSWORD_UPPER, |
379 | + unicode(self.ui.ui.password_assistance.text()), |
380 | + ) |
381 | + self.assertIn( |
382 | + common.NORMAL % common.PASSWORD_DIGIT, |
383 | unicode(self.ui.ui.password_assistance.text()), |
384 | ) |
385 | |
386 | @@ -343,16 +172,6 @@ |
387 | self.ui.on_currentIdChanged(self.ui.CONGRATULATIONS_PAGE) |
388 | self.assertTrue(self.ui.sideWidget().ui.states_frame.isVisible()) |
389 | |
390 | - def test_check_valid(self): |
391 | - """Check the propery value of a QLineEdit marked as valid.""" |
392 | - self.ui.check_as_valid(self.ui.ui.name_edit) |
393 | - self.assertFalse(self.ui.ui.name_edit.property("formError").toBool()) |
394 | - |
395 | - def test_check_invalid(self): |
396 | - """Check the propery value of a QLineEdit marked as invalid.""" |
397 | - self.ui.check_as_invalid(self.ui.ui.name_edit) |
398 | - self.assertTrue(self.ui.ui.name_edit.property("formError").toBool()) |
399 | - |
400 | def test_focus_changed_1(self): |
401 | """Check functions execution when focus_changed() is executed.""" |
402 | self.patch(self.ui, 'validation_functions', FakeValidationDict()) |
Needs this branch: https:/ /code.launchpad .net/~diegosarm entero/ ubuntu- sso-client/ reset-password