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
=== modified file 'ubuntu_sso/qt/controllers.py'
--- ubuntu_sso/qt/controllers.py 2011-08-30 12:48:19 +0000
+++ ubuntu_sso/qt/controllers.py 2011-09-07 15:51:22 +0000
@@ -240,7 +240,8 @@
240 # let the user know240 # let the user know
241 logger.error('Got error when login %s, error: %s',241 logger.error('Got error when login %s, error: %s',
242 self.view.wizard().app_name, error)242 self.view.wizard().app_name, error)
243 self.message_box.critical(_build_general_error_message(error))243 self.message_box.critical(_build_general_error_message(error),
244 self.view)
244245
245 def on_logged_in(self, app_name, result):246 def on_logged_in(self, app_name, result):
246 """We managed to log in."""247 """We managed to log in."""
@@ -418,14 +419,15 @@
418 def on_captcha_generation_error(self, error):419 def on_captcha_generation_error(self, error):
419 """An error ocurred."""420 """An error ocurred."""
420 logger.debug('SetUpAccountController.on_captcha_generation_error')421 logger.debug('SetUpAccountController.on_captcha_generation_error')
421 self.message_box.critical(CAPTCHA_LOAD_ERROR)422 self.message_box.critical(CAPTCHA_LOAD_ERROR, self.view)
422423
423 def on_user_registration_error(self, app_name, error):424 def on_user_registration_error(self, app_name, error):
424 """Let the user know we could not register."""425 """Let the user know we could not register."""
425 logger.debug('SetUpAccountController.on_user_registration_error')426 logger.debug('SetUpAccountController.on_user_registration_error')
426 # errors are returned as a dict with the data we want to show.427 # errors are returned as a dict with the data we want to show.
427 self._refresh_captcha()428 self._refresh_captcha()
428 self.message_box.critical(_build_general_error_message(error))429 self.message_box.critical(_build_general_error_message(error),
430 self.view)
429431
430 def on_user_registered(self, app_name, result):432 def on_user_registered(self, app_name, result):
431 """Execute when the user did register."""433 """Execute when the user did register."""
@@ -442,18 +444,18 @@
442 confirm_password = unicode(self.view.ui.confirm_password_edit.text())444 confirm_password = unicode(self.view.ui.confirm_password_edit.text())
443 captcha_solution = unicode(self.view.ui.captcha_solution_edit.text())445 captcha_solution = unicode(self.view.ui.captcha_solution_edit.text())
444 if not is_correct_email(email):446 if not is_correct_email(email):
445 self.message_box.critical(EMAIL_INVALID)447 self.message_box.critical(EMAIL_INVALID, self.view)
446 if email != confirm_email:448 if email != confirm_email:
447 self.message_box.critical(EMAIL_MISMATCH)449 self.message_box.critical(EMAIL_MISMATCH, self.view)
448 return False450 return False
449 if not is_min_required_password(password):451 if not is_min_required_password(password):
450 self.message_box.critical(PASSWORD_TOO_WEAK)452 self.message_box.critical(PASSWORD_TOO_WEAK, self.view)
451 return False453 return False
452 if password != confirm_password:454 if password != confirm_password:
453 self.message_box.critical(PASSWORD_MISMATCH)455 self.message_box.critical(PASSWORD_MISMATCH, self.view)
454 return False456 return False
455 if not captcha_solution:457 if not captcha_solution:
456 self.message_box.critical(CAPTCHA_REQUIRED_ERROR)458 self.message_box.critical(CAPTCHA_REQUIRED_ERROR, self.view)
457 return False459 return False
458 return True460 return True
459461
@@ -582,7 +584,7 @@
582 msg = error.get('email_token')584 msg = error.get('email_token')
583 if msg is None:585 if msg is None:
584 msg = _build_general_error_message(error)586 msg = _build_general_error_message(error)
585 self.message_box.critical(msg)587 self.message_box.critical(msg, self.view)
586588
587 #pylint: disable=C0103589 #pylint: disable=C0103
588 def pageInitialized(self):590 def pageInitialized(self):
@@ -773,7 +775,8 @@
773 """Let the user know that there was an error."""775 """Let the user know that there was an error."""
774 logger.error('Got error changing password for %s, error: %s',776 logger.error('Got error changing password for %s, error: %s',
775 self.view.wizard().app_name, error)777 self.view.wizard().app_name, error)
776 self.message_box.critical(_build_general_error_message(error))778 self.message_box.critical(_build_general_error_message(error),
779 self.view)
777780
778 def set_new_password(self):781 def set_new_password(self):
779 """Request a new password to be set."""782 """Request a new password to be set."""
780783
=== modified file 'ubuntu_sso/qt/tests/test_windows.py'
--- ubuntu_sso/qt/tests/test_windows.py 2011-08-30 12:10:40 +0000
+++ ubuntu_sso/qt/tests/test_windows.py 2011-09-07 15:51:22 +0000
@@ -279,39 +279,41 @@
279 def test_error_message_key(self):279 def test_error_message_key(self):
280 """Test that on_login_error reacts to errors with "error_message"."""280 """Test that on_login_error reacts to errors with "error_message"."""
281 self.on_error_method({"error_message": "WORRY!"})281 self.on_error_method({"error_message": "WORRY!"})
282 self.assertEqual(self.message_box.critical_args, (('WORRY!',), {}))282 self.assertEqual(self.message_box.critical_args, (('WORRY!',
283 self.controller.view), {}))
283284
284 def test_message_key(self):285 def test_message_key(self):
285 """Test that on_login_error reacts to errors with "message"."""286 """Test that on_login_error reacts to errors with "message"."""
286 self.on_error_method({"message": "WORRY!"})287 self.on_error_method({"message": "WORRY!"})
287 self.assertEqual(self.message_box.critical_args, (('WORRY!',), {}))288 self.assertEqual(self.message_box.critical_args, (('WORRY!',
289 self.controller.view), {}))
288290
289 def test_broken_error(self):291 def test_broken_error(self):
290 """Test that on_login_error reacts to broken errors."""292 """Test that on_login_error reacts to broken errors."""
291 self.on_error_method({"boo!": "WORRY!"})293 self.on_error_method({"boo!": "WORRY!"})
292 self.assertEqual(self.message_box.critical_args,294 self.assertEqual(self.message_box.critical_args,
293 (("Error: {'boo!': 'WORRY!'}",), {}))295 (("Error: {'boo!': 'WORRY!'}", self.controller.view), {}))
294296
295 def test_all_and_message(self):297 def test_all_and_message(self):
296 """Test that on_login_error reacts to broken errors."""298 """Test that on_login_error reacts to broken errors."""
297 self.on_error_method(299 self.on_error_method(
298 {"message": "WORRY!", "__all__": "MORE!"})300 {"message": "WORRY!", "__all__": "MORE!"})
299 self.assertEqual(self.message_box.critical_args,301 self.assertEqual(self.message_box.critical_args,
300 (('MORE!\nWORRY!',), {}))302 (('MORE!\nWORRY!', self.controller.view), {}))
301303
302 def test_all_and_error_message(self):304 def test_all_and_error_message(self):
303 """Test that on_login_error reacts to broken errors."""305 """Test that on_login_error reacts to broken errors."""
304 self.on_error_method(306 self.on_error_method(
305 {"error_message": "WORRY!", "__all__": "MORE!"})307 {"error_message": "WORRY!", "__all__": "MORE!"})
306 self.assertEqual(self.message_box.critical_args,308 self.assertEqual(self.message_box.critical_args,
307 (('MORE!\nWORRY!',), {}))309 (('MORE!\nWORRY!', self.controller.view), {}))
308310
309 def test_only_all(self):311 def test_only_all(self):
310 """Test that on_login_error reacts to broken errors."""312 """Test that on_login_error reacts to broken errors."""
311 self.on_error_method(313 self.on_error_method(
312 {"__all__": "MORE!"})314 {"__all__": "MORE!"})
313 self.assertEqual(self.message_box.critical_args,315 self.assertEqual(self.message_box.critical_args,
314 (('MORE!',), {}))316 (('MORE!', self.controller.view), {}))
315317
316318
317class EmailVerificationControllerErrorTestCase(319class EmailVerificationControllerErrorTestCase(
@@ -552,7 +554,7 @@
552 self.mocker.result(password)554 self.mocker.result(password)
553 self.view.ui.captcha_solution_edit.text()555 self.view.ui.captcha_solution_edit.text()
554 self.mocker.result(captcha_solution)556 self.mocker.result(captcha_solution)
555 self.message_box.critical(EMAIL_MISMATCH)557 self.message_box.critical(EMAIL_MISMATCH, self.controller.view)
556 self.mocker.replay()558 self.mocker.replay()
557 self.assertFalse(self.controller.validate_form())559 self.assertFalse(self.controller.validate_form())
558560
@@ -571,7 +573,7 @@
571 self.mocker.result(captcha_solution)573 self.mocker.result(captcha_solution)
572 self.view.ui.confirm_password_edit.text()574 self.view.ui.confirm_password_edit.text()
573 self.mocker.result(weak_password)575 self.mocker.result(weak_password)
574 self.message_box.critical(PASSWORD_TOO_WEAK)576 self.message_box.critical(PASSWORD_TOO_WEAK, self.controller.view)
575 self.mocker.replay()577 self.mocker.replay()
576 self.assertFalse(self.controller.validate_form())578 self.assertFalse(self.controller.validate_form())
577579
@@ -590,7 +592,7 @@
590 self.mocker.result('other_password')592 self.mocker.result('other_password')
591 self.view.ui.captcha_solution_edit.text()593 self.view.ui.captcha_solution_edit.text()
592 self.mocker.result(captcha_solution)594 self.mocker.result(captcha_solution)
593 self.message_box.critical(PASSWORD_MISMATCH)595 self.message_box.critical(PASSWORD_MISMATCH, self.controller.view)
594 self.mocker.replay()596 self.mocker.replay()
595 self.assertFalse(self.controller.validate_form())597 self.assertFalse(self.controller.validate_form())
596598
@@ -609,7 +611,7 @@
609 self.mocker.result(password)611 self.mocker.result(password)
610 self.view.ui.captcha_solution_edit.text()612 self.view.ui.captcha_solution_edit.text()
611 self.mocker.result(captcha_solution)613 self.mocker.result(captcha_solution)
612 self.message_box.critical(CAPTCHA_REQUIRED_ERROR)614 self.message_box.critical(CAPTCHA_REQUIRED_ERROR, self.controller.view)
613 self.mocker.replay()615 self.mocker.replay()
614 self.assertFalse(self.controller.validate_form())616 self.assertFalse(self.controller.validate_form())
615617
@@ -691,7 +693,7 @@
691 self.controller.on_user_registration_error('TestApp',693 self.controller.on_user_registration_error('TestApp',
692 {'__all__': "Error in All"})694 {'__all__': "Error in All"})
693 self.assertEqual(self.message_box.critical_args, ((695 self.assertEqual(self.message_box.critical_args, ((
694 "Error in All", ), {}))696 "Error in All", self.controller.view), {}))
695697
696 def test_on_user_registration_all_fields(self):698 def test_on_user_registration_all_fields(self):
697 """Pass all known error keys, plus unknown one."""699 """Pass all known error keys, plus unknown one."""
@@ -702,7 +704,7 @@
702 'unknownfield': "Error in unknown",704 'unknownfield': "Error in unknown",
703 })705 })
704 self.assertEqual(self.message_box.critical_args, ((706 self.assertEqual(self.message_box.critical_args, ((
705 "Error in All", ), {}))707 "Error in All", self.controller.view), {}))
706708
707709
708class EmailVerificationControllerTestCase(MockerTestCase):710class EmailVerificationControllerTestCase(MockerTestCase):
@@ -785,7 +787,8 @@
785 app_name = 'app_name'787 app_name = 'app_name'
786 self.controller.on_email_validation_error(app_name, error)788 self.controller.on_email_validation_error(app_name, error)
787 self.assertEqual(self.message_box.critical_args,789 self.assertEqual(self.message_box.critical_args,
788 (("Error: {'errtype': 'BadTokenError'}",), {}))790 (("Error: {'errtype': 'BadTokenError'}",
791 self.controller.view), {}))
789792
790793
791class ErrorControllerTestCase(MockerTestCase):794class ErrorControllerTestCase(MockerTestCase):

Subscribers

People subscribed via source and target branches