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
1=== modified file 'pylintrc'
2--- pylintrc 2011-04-12 14:45:36 +0000
3+++ pylintrc 2011-07-06 17:12:36 +0000
4@@ -58,7 +58,7 @@
5
6 # Set the output format. Available formats are text, parseable, colorized, msvs
7 # (visual studio) and html
8-output-format=colorized
9+output-format=text
10
11 # Include message's id in output
12 include-ids=yes
13
14=== modified file 'ubuntu_sso/gtk/gui.py'
15--- ubuntu_sso/gtk/gui.py 2011-03-30 18:50:04 +0000
16+++ ubuntu_sso/gtk/gui.py 2011-07-06 17:12:36 +0000
17@@ -1027,7 +1027,7 @@
18
19 @log_call
20 def on_user_registration_error(self, app_name, error, *args, **kwargs):
21- """Captcha image generation failed."""
22+ """Error in the data provided for registration."""
23 msg = error.get('email')
24 if msg is not None:
25 self.email1_entry.set_warning(msg)
26
27=== modified file 'ubuntu_sso/qt/controllers.py'
28--- ubuntu_sso/qt/controllers.py 2011-07-04 22:27:08 +0000
29+++ ubuntu_sso/qt/controllers.py 2011-07-06 17:12:36 +0000
30@@ -200,7 +200,7 @@
31 logger.error('Got error when login %s, error: %s',
32 self.view.wizard().app_name, error)
33 self.message_box.critical(self.view, self.view.wizard().app_name,
34- str(error))
35+ error['message'])
36
37 def on_logged_in(self, app_name, result):
38 """We managed to log in."""
39@@ -353,8 +353,13 @@
40 def on_user_registration_error(self, app_name, error):
41 """Let the user know we could not register."""
42 logger.debug('SetUpAccountController.on_user_registration_error')
43- # error are returned as a dict with the data we want to show.
44- self.message_box.critical(self.view, error['errtype'], error['email'])
45+ # errors are returned as a dict with the data we want to show.
46+ self._refresh_captcha()
47+ errors = [v for _, v in sorted(error.iteritems())]
48+ self.message_box.critical(
49+ self.view,
50+ self.view.wizard().app_name,
51+ '\n'.join(errors))
52
53 def on_user_registered(self, app_name, result):
54 """Execute when the user did register."""
55
56=== modified file 'ubuntu_sso/qt/tests/test_windows.py'
57--- ubuntu_sso/qt/tests/test_windows.py 2011-07-04 22:27:08 +0000
58+++ ubuntu_sso/qt/tests/test_windows.py 2011-07-06 17:12:36 +0000
59@@ -16,6 +16,8 @@
60 # with this program. If not, see <http://www.gnu.org/licenses/>.
61 """Test the ui controllers."""
62
63+from twisted.trial.unittest import TestCase
64+
65 from mocker import ANY, MATCH, MockerTestCase
66
67 from PyQt4.QtGui import QWizard
68@@ -389,6 +391,78 @@
69 self.controller._set_line_edits_validations()
70
71
72+class FakeMessageBox(object):
73+
74+ """A fake message box."""
75+
76+ args = None
77+ critical_args = None
78+
79+ def __init__(self, *args, **kwargs):
80+ self.args = (args, kwargs)
81+
82+ def critical(self, *args, **kwargs):
83+ """Fake critical popup."""
84+ self.critical_args = (args, kwargs)
85+
86+
87+class FakeView(object):
88+
89+ """A fake view"""
90+
91+ app_name = "TestApp"
92+
93+ def wizard(self):
94+ """Use itself as a fake wizard, too."""
95+ return self
96+
97+
98+class SetupAccountControllerTest2(TestCase):
99+
100+ """Tests for SetupAccountController, but without Mocker"""
101+
102+ def setUp(self):
103+ super(SetupAccountControllerTest2, self).setUp()
104+ self.message_box = FakeMessageBox()
105+ self.controller = SetUpAccountController(message_box=self.message_box)
106+ self.patch(self.controller, '_refresh_captcha', self._set_called)
107+ self.patch(self.controller, 'view', FakeView())
108+ self._called = False
109+
110+ def _set_called(self, *args, **kwargs):
111+ """Store 'args' and 'kwargs' for test assertions."""
112+ self._called = (args, kwargs)
113+
114+ def test_on_user_registration_refresh_captcha(self):
115+ """If there is a user reg. error, captcha should refresh."""
116+ self.controller.on_user_registration_error('TestApp', {})
117+ self.assertEqual(self._called, ((), {}))
118+
119+ def test_on_user_registration_all_only(self):
120+ """Pass only a __all__ error key."""
121+ self.controller.on_user_registration_error('TestApp',
122+ {'__all__': "Error in All"})
123+ self.assertEqual(self.message_box.critical_args, ((
124+ self.controller.view,
125+ self.controller.view.app_name,
126+ "Error in All"), {}))
127+
128+ def test_on_user_registration_all_fields(self):
129+ """Pass all known error keys, plus unknown one."""
130+ self.controller.on_user_registration_error('TestApp',
131+ {'__all__': "Error in All",
132+ 'email': "Error in email",
133+ 'pasword': "Error in password",
134+ 'unknownfield': "Error in unknown",
135+ })
136+ self.assertEqual(self.message_box.critical_args, ((
137+ self.controller.view,
138+ self.controller.view.app_name,
139+ "Error in All\nError in email\n"
140+ "Error in password\nError in unknown",
141+ ), {}))
142+
143+
144 class TosControllerTestCase(MockerTestCase):
145 """Test the tos controller."""
146

Subscribers

People subscribed via source and target branches