Merge lp:~ralsina/ubuntu-sso-client/fix_805405 into lp:ubuntu-sso-client

Proposed by Roberto Alsina
Status: Merged
Approved by: Roberto Alsina
Approved revision: 747
Merged at revision: 733
Proposed branch: lp:~ralsina/ubuntu-sso-client/fix_805405
Merge into: lp:ubuntu-sso-client
Diff against target: 145 lines (+84/-5)
4 files modified
pylintrc (+1/-1)
ubuntu_sso/gtk/gui.py (+1/-1)
ubuntu_sso/qt/controllers.py (+8/-3)
ubuntu_sso/qt/tests/test_windows.py (+74/-0)
To merge this branch: bzr merge lp:~ralsina/ubuntu-sso-client/fix_805405
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) Approve
Natalia Bidart (community) Approve
Review via email: mp+66784@code.launchpad.net

Commit message

Fix an exception when the user entered the captcha wrong, show a message instead of a dict in another case.

Description of the change

Fix an exception when the user entered the captcha wrong, show a message instead of a dict in another case.

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

== Python Lint Notices ==

ubuntu_sso/qt/tests/test_windows.py:
    403: [C0111, FakeMessageBox.critical] Missing docstring
    406: [C0111, FakeView] Missing docstring
    409: [C0111, FakeView.wizard] Missing docstring
    429: [C0324, SetupAccountControllerTest2.test_on_user_registration_refresh_captcha] Comma not followed by a space
            self.controller.on_user_registration_error('TestApp',{})
                                                                ^^
    430: [C0324, SetupAccountControllerTest2.test_on_user_registration_refresh_captcha] Comma not followed by a space
            self.assertEqual(self._called,((),{}))
                                         ^^
    441: [E0102, SetupAccountControllerTest2.test_on_user_registration_all_only] method already defined line 432

review: Needs Fixing
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Pep8 issues:

ubuntu_sso/qt/tests/test_windows.py:456:48: E202 whitespace before '}'
ubuntu_sso/qt/tests/test_windows.py:461:80: E202 whitespace before ')'

review: Needs Fixing
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Works great!

review: Approve
Revision history for this message
Manuel de la Peña (mandel) :
review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (50.9 KiB)

The attempt to merge lp:~ralsina/ubuntu-sso-client/fix_805405 into lp:ubuntu-sso-client failed. Below is the output from the failed tests.

Running test suite for ubuntu_sso
Xlib: extension "RANDR" missing on display ":99".
ubuntu_sso.utils.tests.test_ui
  GetPasswordStrengTestCase
    test_eight_chars_and_num ... [OK]
    test_eight_chars_low_and_cap ... [OK]
    test_eight_chars_low_canp_num ... [OK]
    test_eight_chars_password ... [OK]
    test_eiqgh_chars_and_special ... [OK]
    test_eleven_chars_and_num ... [OK]
    test_eleven_chars_low_cap ... [OK]
    test_eleven_num_low_cap ... [OK]
    test_eleven_num_special ... [OK]
    test_long_password ... [OK]
    test_small_password ... [OK]
    test_too_small_password ... [OK]
  IsCorrectEmailAddress
    test_is_correct_email_false ... [OK]
    test_is_correct_email_true ... [OK]
  IsMinRequiredPasswordTestCase
    test_correct_password ... [OK]
    test_no_enough_chars ... [OK]
    test_no_number ... [OK]
    test_no_uppercase ... [OK]
ubuntu_sso.utils.tests.test_txsecrets
  AltItemTestCase
    test_create_item_four_fields_per_secret ... [OK]
    test_get_value_four_fields_per_secret ... [OK]
  BaseTestCase
    runTest ... [OK]
  CollectionTestCase
    test_create_item ... ERROR:dbus.connection:Unable to set arguments ({'org.freedesktop.Secret.Collection.Label': dbus.String(u'sample_keyring', variant_level=1)}, '') according to signature u'a{sv}': <type 'exceptions.TypeError'>: Fewer items found in D-Bus signature than in Python arguments
                                                  [OK]
    test_create_item_prompt ... ERROR:dbus.connection:Unable to set arguments ({'org.freedesktop.Secret.Collection.Label': dbus.String(u'sample_keyring', variant_level=1)}, '') according to signature u'a{sv}': <type 'exceptions.TypeError'>: Fewer items found in D-Bus signature than in Python arguments
                                           [OK]
    test_create_item_prompt_dismissed ... ERROR:dbus.connection:Unable to set arguments ({'org.freedesktop.Secret.Collection.Label': dbus.String(u'sample_keyring', variant_level=1)}, '') according to signature u'a{sv}': <type 'exceptions.TypeError'>: Fewer items found in D-Bus signature than in Python arguments
                                 [OK]
    test_create_item_throws_dbus_er...

747. By Roberto Alsina

Lint notice

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'pylintrc'
--- pylintrc 2011-04-12 14:45:36 +0000
+++ pylintrc 2011-07-06 17:12:36 +0000
@@ -58,7 +58,7 @@
5858
59# Set the output format. Available formats are text, parseable, colorized, msvs59# Set the output format. Available formats are text, parseable, colorized, msvs
60# (visual studio) and html60# (visual studio) and html
61output-format=colorized61output-format=text
6262
63# Include message's id in output63# Include message's id in output
64include-ids=yes64include-ids=yes
6565
=== modified file 'ubuntu_sso/gtk/gui.py'
--- ubuntu_sso/gtk/gui.py 2011-03-30 18:50:04 +0000
+++ ubuntu_sso/gtk/gui.py 2011-07-06 17:12:36 +0000
@@ -1027,7 +1027,7 @@
10271027
1028 @log_call1028 @log_call
1029 def on_user_registration_error(self, app_name, error, *args, **kwargs):1029 def on_user_registration_error(self, app_name, error, *args, **kwargs):
1030 """Captcha image generation failed."""1030 """Error in the data provided for registration."""
1031 msg = error.get('email')1031 msg = error.get('email')
1032 if msg is not None:1032 if msg is not None:
1033 self.email1_entry.set_warning(msg)1033 self.email1_entry.set_warning(msg)
10341034
=== modified file 'ubuntu_sso/qt/controllers.py'
--- ubuntu_sso/qt/controllers.py 2011-07-04 22:27:08 +0000
+++ ubuntu_sso/qt/controllers.py 2011-07-06 17:12:36 +0000
@@ -200,7 +200,7 @@
200 logger.error('Got error when login %s, error: %s',200 logger.error('Got error when login %s, error: %s',
201 self.view.wizard().app_name, error)201 self.view.wizard().app_name, error)
202 self.message_box.critical(self.view, self.view.wizard().app_name,202 self.message_box.critical(self.view, self.view.wizard().app_name,
203 str(error))203 error['message'])
204204
205 def on_logged_in(self, app_name, result):205 def on_logged_in(self, app_name, result):
206 """We managed to log in."""206 """We managed to log in."""
@@ -353,8 +353,13 @@
353 def on_user_registration_error(self, app_name, error):353 def on_user_registration_error(self, app_name, error):
354 """Let the user know we could not register."""354 """Let the user know we could not register."""
355 logger.debug('SetUpAccountController.on_user_registration_error')355 logger.debug('SetUpAccountController.on_user_registration_error')
356 # error are returned as a dict with the data we want to show.356 # errors are returned as a dict with the data we want to show.
357 self.message_box.critical(self.view, error['errtype'], error['email'])357 self._refresh_captcha()
358 errors = [v for _, v in sorted(error.iteritems())]
359 self.message_box.critical(
360 self.view,
361 self.view.wizard().app_name,
362 '\n'.join(errors))
358363
359 def on_user_registered(self, app_name, result):364 def on_user_registered(self, app_name, result):
360 """Execute when the user did register."""365 """Execute when the user did register."""
361366
=== modified file 'ubuntu_sso/qt/tests/test_windows.py'
--- ubuntu_sso/qt/tests/test_windows.py 2011-07-04 22:27:08 +0000
+++ ubuntu_sso/qt/tests/test_windows.py 2011-07-06 17:12:36 +0000
@@ -16,6 +16,8 @@
16# with this program. If not, see <http://www.gnu.org/licenses/>.16# with this program. If not, see <http://www.gnu.org/licenses/>.
17"""Test the ui controllers."""17"""Test the ui controllers."""
1818
19from twisted.trial.unittest import TestCase
20
19from mocker import ANY, MATCH, MockerTestCase21from mocker import ANY, MATCH, MockerTestCase
2022
21from PyQt4.QtGui import QWizard23from PyQt4.QtGui import QWizard
@@ -389,6 +391,78 @@
389 self.controller._set_line_edits_validations()391 self.controller._set_line_edits_validations()
390392
391393
394class FakeMessageBox(object):
395
396 """A fake message box."""
397
398 args = None
399 critical_args = None
400
401 def __init__(self, *args, **kwargs):
402 self.args = (args, kwargs)
403
404 def critical(self, *args, **kwargs):
405 """Fake critical popup."""
406 self.critical_args = (args, kwargs)
407
408
409class FakeView(object):
410
411 """A fake view"""
412
413 app_name = "TestApp"
414
415 def wizard(self):
416 """Use itself as a fake wizard, too."""
417 return self
418
419
420class SetupAccountControllerTest2(TestCase):
421
422 """Tests for SetupAccountController, but without Mocker"""
423
424 def setUp(self):
425 super(SetupAccountControllerTest2, self).setUp()
426 self.message_box = FakeMessageBox()
427 self.controller = SetUpAccountController(message_box=self.message_box)
428 self.patch(self.controller, '_refresh_captcha', self._set_called)
429 self.patch(self.controller, 'view', FakeView())
430 self._called = False
431
432 def _set_called(self, *args, **kwargs):
433 """Store 'args' and 'kwargs' for test assertions."""
434 self._called = (args, kwargs)
435
436 def test_on_user_registration_refresh_captcha(self):
437 """If there is a user reg. error, captcha should refresh."""
438 self.controller.on_user_registration_error('TestApp', {})
439 self.assertEqual(self._called, ((), {}))
440
441 def test_on_user_registration_all_only(self):
442 """Pass only a __all__ error key."""
443 self.controller.on_user_registration_error('TestApp',
444 {'__all__': "Error in All"})
445 self.assertEqual(self.message_box.critical_args, ((
446 self.controller.view,
447 self.controller.view.app_name,
448 "Error in All"), {}))
449
450 def test_on_user_registration_all_fields(self):
451 """Pass all known error keys, plus unknown one."""
452 self.controller.on_user_registration_error('TestApp',
453 {'__all__': "Error in All",
454 'email': "Error in email",
455 'pasword': "Error in password",
456 'unknownfield': "Error in unknown",
457 })
458 self.assertEqual(self.message_box.critical_args, ((
459 self.controller.view,
460 self.controller.view.app_name,
461 "Error in All\nError in email\n"
462 "Error in password\nError in unknown",
463 ), {}))
464
465
392class TosControllerTestCase(MockerTestCase):466class TosControllerTestCase(MockerTestCase):
393 """Test the tos controller."""467 """Test the tos controller."""
394468

Subscribers

People subscribed via source and target branches