1
=== modified file 'setup.py'
2
--- old/setup.py 2012-02-15 16:32:29 +0000
3
+++ new/setup.py 2012-02-17 17:20:51 +0000
7
"""Execute the command."""
8
- # pylint: disable=W0703
11
- except Exception, e:
12
- self.warn("Error wrapping uic to use gettext: %s" % e)
13
basepath = os.path.join('data', 'qt')
14
# TODO: build the resource files so that we can include them
15
#self.build_rc(os.path.join(basepath, 'icons_rc.py'),
18
build_extra.build_extra.run(self)
20
- # pylint: disable=E1002
25
- """Wrap uic to use gettext's _() in place of tr()"""
29
- from PyQt4.uic.Compiler import compiler, qtproxies, indenter
31
- # pylint: disable=C0103
32
- class _UICompiler(compiler.UICompiler):
33
- """Speciallized compiler for qt .ui files."""
34
- def createToplevelWidget(self, classname, widgetname):
35
- o = indenter.getIndenter()
37
- o.write('from gettext import gettext as _')
38
- return super(_UICompiler, self).createToplevelWidget(classname,
40
- compiler.UICompiler = _UICompiler
42
- class _i18n_string(qtproxies.i18n_string):
43
- """Provide a translated text."""
46
- return "_('%s')" % self.string.encode('string-escape')
48
- qtproxies.i18n_string = _i18n_string
50
- cls._wrappeduic = True
51
- # pylint: enable=C0103
52
- # pylint: enable=E1002
55
class SSOClean(DistUtilsExtra.auto.clean_build_tree):
56
"""Class to clean up after the build."""
58
=== modified file 'ubuntu_sso/credentials.py'
59
--- old/ubuntu_sso/credentials.py 2012-02-11 19:25:01 +0000
60
+++ new/ubuntu_sso/credentials.py 2012-02-17 17:19:43 +0000
62
value = getattr(self, arg)
64
args.append('--%s' % arg)
65
- args.append("%s" % str(value))
66
+ if not isinstance(value, basestring):
71
args.append('--login_only')
73
=== modified file 'ubuntu_sso/gtk/gui.py'
74
--- old/ubuntu_sso/gtk/gui.py 2012-02-11 19:25:01 +0000
75
+++ new/ubuntu_sso/gtk/gui.py 2012-02-16 21:39:13 +0000
77
# To be replaced by values from the theme (LP: #616526)
78
HELP_TEXT_COLOR = parse_color("#bfbfbf")
79
WARNING_TEXT_COLOR = parse_color("red")
80
+LARGE_MARKUP = u'<span size="x-large">%s</span>'
87
"""Get text only if it's not the label nor empty."""
88
- result = super(LabeledEntry, self).get_text()
89
+ result = super(LabeledEntry, self).get_text().decode('utf8')
90
if result == self.label or result.isspace():
95
def set_warning(self, warning_msg):
97
self._done = False # whether the whole process was completed or not
99
self.app_name = app_name
100
- self.app_label = '<b>%s</b>' % self.app_name
101
- self.ping_url = kwargs.get('ping_url', '')
102
- self.tc_url = kwargs.get('tc_url', '')
103
- self.help_text = kwargs.get('help_text', '')
104
+ self.app_label = u'<b>%s</b>' % self.app_name
105
+ self.ping_url = kwargs.get('ping_url', u'')
106
+ self.tc_url = kwargs.get('tc_url', u'')
107
+ self.help_text = kwargs.get('help_text', u'')
108
self.login_only = kwargs.get('login_only', False)
109
window_id = kwargs.get('window_id', 0)
110
self.close_callback = kwargs.get('close_callback', NO_OP)
111
@@ -338,15 +339,14 @@
112
def success_vbox(self):
113
"""The success page."""
114
message = SUCCESS % {'app_name': self.app_name}
115
- message = '<span size="x-large">%s</span>' % message
116
+ message = LARGE_MARKUP % message
117
self.finish_vbox.label.set_markup(message)
118
return self.finish_vbox
121
def error_vbox(self):
122
"""The error page."""
123
- self.finish_vbox.label.set_markup('<span size="x-large">%s</span>' %
125
+ self.finish_vbox.label.set_markup(LARGE_MARKUP % ERROR)
126
return self.finish_vbox
130
result = f(app_name, *args, **kwargs)
132
logger.info('%s: ignoring call since received app_name '\
133
- '"%s" (expected "%s")',
134
+ '%r (expected %r)',
135
f.__name__, app_name, self.app_name)
140
def _set_header(self, header):
141
"""Set 'header' as the window title and header."""
142
- markup = '<span size="x-large">%s</span>'
143
- self.header_label.set_markup(markup % header)
144
+ self.header_label.set_markup(LARGE_MARKUP % header)
145
self.window.set_title(self.header_label.get_text()) # avoid markup
147
def _set_current_page(self, current_page, warning_text=None):
149
f = self.backend.register_user
150
error_handler = partial(self._handle_error, f,
151
self.on_user_registration_error)
152
- f(unicode(self.app_name), email1.decode('utf8'),
153
- password1.decode('utf8'), name.decode('utf8'),
154
- unicode(self._captcha_id), captcha_solution.decode('utf8'),
155
+ f(self.app_name, self.user_email, self.user_password, name,
156
+ self._captcha_id, captcha_solution,
157
reply_handler=NO_OP, error_handler=error_handler)
159
def on_verify_token_button_clicked(self, *args, **kwargs):
160
@@ -1035,7 +1033,7 @@
161
"""Captcha image has been generated and is available to be shown."""
162
if captcha_id is None:
163
logger.warning('on_captcha_generated: captcha_id is None for '
164
- 'app_name "%s".', app_name)
165
+ 'app_name %r.', app_name)
166
self._captcha_id = captcha_id
167
self._set_captcha_image()
170
=== modified file 'ubuntu_sso/gtk/tests/test_gui.py'
171
--- old/ubuntu_sso/gtk/tests/test_gui.py 2012-02-11 01:51:57 +0000
172
+++ new/ubuntu_sso/gtk/tests/test_gui.py 2012-02-16 22:09:33 +0000
175
assert tmp.parse(gdk_color.to_string())
177
- msg = 'Text color must be "%s" (got "%s" instead).'
178
+ msg = 'Text color must be %r (got %r instead).'
179
self.assertEqual(rgba_color, tmp, msg % (rgba_color, tmp))
181
def assert_backend_called(self, method, *args, **kwargs):
183
def assert_correct_label(self):
184
"""Check that the entry has the correct label."""
185
# text content is correct
186
- msg = 'Text content must be "%s" (got "%s" instead).'
187
+ msg = 'Text content must be %r (got %r instead).'
188
expected = self.label
189
actual = super(gui.LabeledEntry, self.entry).get_text()
190
self.assertEqual(expected, actual, msg % (expected, actual))
193
def test_tooltip(self):
194
"""Entry have the correct tooltip."""
195
- msg = 'Tooltip must be "%s" (got "%s" instead).'
196
+ msg = 'Tooltip must be %r (got %r instead).'
197
expected = self.label
198
actual = self.entry.get_tooltip_text()
202
def assert_entries_are_packed_to_ui(self, container_name, entries):
203
"""Every entry is properly packed in the ui 'container_name'."""
204
- msg = 'Entry "%s" must be packed in "%s" but is not.'
205
+ msg = 'Entry %r must be packed in %r but is not.'
206
container = getattr(self.ui, container_name)
208
name = '%s_entry' % kind
211
def assert_warnings_visibility(self, visible=False):
212
"""Every warning label should be 'visible'."""
213
- msg = '"%s" should have %sempty content.'
214
+ msg = '%r should have %sempty content.'
215
for name in self.ui.widgets:
216
widget = getattr(self.ui, name)
217
if 'warning' in name:
219
self.assertTrue(label.get_property('visible'))
221
# warning content is correct
222
- actual = label.get_text()
223
+ actual = label.get_text().decode('utf-8')
224
self.assertEqual(actual, message)
226
# content color is correct
229
def test_initial_text_for_entries(self):
230
"""Entries have the correct text at startup."""
231
- msg = 'Text for "%s" must be "%s" (got "%s" instead).'
232
+ msg = 'Text for %r must be %r (got %r instead).'
233
for name in self.ui.entries:
234
entry = getattr(self.ui, name)
235
expected = getattr(gui.utils.ui, name.upper())
236
@@ -557,14 +557,14 @@
238
def test_entries_activates_default(self):
239
"""Entries have the activates default prop set."""
240
- msg = '"%s" must have activates_default set to True.'
241
+ msg = '%r must have activates_default set to True.'
242
for name in self.ui.entries:
243
entry = getattr(self.ui, name)
244
self.assertTrue(entry.get_activates_default(), msg % (name,))
246
def test_password_fields_are_password(self):
247
"""Password fields have the is_password flag set."""
248
- msg = '"%s" should be a password LabeledEntry instance.'
249
+ msg = '%r should be a password LabeledEntry instance.'
250
passwords = filter(lambda name: 'password' in name,
252
for name in passwords:
254
def test_cancel_buttons_close_window(self):
255
"""Every cancel button should close the window when clicked."""
256
self.patch(self.ui.backend, 'disconnect_from_signal', lambda *a: None)
257
- msg = '"%s" should close the window when clicked.'
258
+ msg = '%r should close the window when clicked.'
259
buttons = filter(lambda name: 'cancel_button' in name or
260
'close_button' in name, self.ui.widgets)
262
@@ -597,15 +597,16 @@
263
self.ui.finish_success()
264
self.assert_pages_visibility(finish=True)
265
self.assertEqual(gui.SUCCESS % {'app_name': APP_NAME},
266
- self.ui.finish_vbox.label.get_text())
267
- result = self.ui.finish_vbox.label.get_text()
268
+ self.ui.finish_vbox.label.get_text().decode('utf8'))
269
+ result = self.ui.finish_vbox.label.get_text().decode('utf8')
270
self.assertTrue(self.ui.app_name in result)
272
def test_finish_error_shows_error_page(self):
273
"""When calling 'finish_error' the error page is shown."""
274
self.ui.finish_error()
275
self.assert_pages_visibility(finish=True)
276
- self.assertEqual(gui.ERROR, self.ui.finish_vbox.label.get_text())
277
+ self.assertEqual(gui.ERROR,
278
+ self.ui.finish_vbox.label.get_text().decode('utf8'))
281
class SetTransientForTestCase(UbuntuSSOClientTestCase):
284
def test_initial_text_for_header_label(self):
285
"""The header must have the correct text at startup."""
286
- msg = 'Text for the header must be "%s" (got "%s" instead).'
287
+ msg = 'Text for the header must be %r (got %r instead).'
288
expected = gui.JOIN_HEADER_LABEL % {'app_name': APP_NAME}
289
- actual = self.ui.header_label.get_text()
290
+ actual = self.ui.header_label.get_text().decode('utf8')
291
# text content is correct
292
self.assertEqual(expected, actual, msg % (expected, actual))
294
@@ -670,26 +671,26 @@
296
def test_initial_texts_for_checkbuttons(self):
297
"""Check buttons have the correct text at startup."""
298
- msg = 'Text for "%s" must be "%s" (got "%s" instead).'
299
+ msg = 'Text for %r must be %r (got %r instead).'
300
expected = gui.YES_TO_UPDATES % {'app_name': APP_NAME}
301
- actual = self.ui.yes_to_updates_checkbutton.get_label()
302
+ actual = self.ui.yes_to_updates_checkbutton.get_label().decode('utf8')
303
self.assertEqual(expected, actual, msg % ('yes_to_updates_checkbutton',
305
expected = gui.YES_TO_TC % {'app_name': APP_NAME}
306
- actual = self.ui.yes_to_tc_checkbutton.get_label()
307
+ actual = self.ui.yes_to_tc_checkbutton.get_label().decode('utf8')
308
self.assertEqual(expected, actual,
309
msg % ('yes_to_tc_checkbutton', expected, actual))
311
def test_checkbutton_is_checked_at_startup(self):
312
"""Checkbuttons are checked by default."""
313
- msg = '"%s" is checked by default.'
314
+ msg = '%r is checked by default.'
315
name = 'yes_to_updates_checkbutton'
316
widget = getattr(self.ui, name)
317
self.assertTrue(widget.get_active(), msg % name)
319
def test_checkbutton_isnt_checked_at_startup(self):
320
"""Checkbuttons are checked by default."""
321
- msg = '"%s" is checked by default.'
322
+ msg = '%r is checked by default.'
323
name = 'yes_to_tc_checkbutton'
324
widget = getattr(self.ui, name)
325
self.assertFalse(widget.get_active(), msg % name)
327
'the processing spinner should be active.')
328
self.assertTrue(label.get_property('visible'),
329
'the processing label should be visible.')
330
- self.assertEqual(label.get_text(), gui.ONE_MOMENT_PLEASE,
331
+ self.assertEqual(label.get_text().decode('utf8'),
332
+ gui.ONE_MOMENT_PLEASE,
333
'the processing label text must be correct.')
335
def test_captcha_image_is_not_visible_at_startup(self):
337
'the captcha_loading spinner should be active.')
338
self.assertTrue(label.get_property('visible'),
339
'the captcha_loading label should be visible.')
340
- self.assertEqual(label.get_text(), gui.LOADING,
341
+ self.assertEqual(label.get_text().decode('utf8'), gui.LOADING,
342
'the captcha_loading label text must be correct.')
344
def test_join_ok_button_is_disabled_until_captcha_is_available(self):
346
def test_on_captcha_generated_logs_captcha_id_when_none(self):
347
"""If the captcha id is None, a warning is logged."""
348
self.ui.on_captcha_generated(app_name=APP_NAME, captcha_id=None)
349
- self.assertTrue(self.memento.check(logging.WARNING, APP_NAME))
350
+ self.assertTrue(self.memento.check(logging.WARNING, repr(APP_NAME)))
351
self.assertTrue(self.memento.check(logging.WARNING,
352
'captcha_id is None'))
356
def test_login_button_has_correct_wording(self):
357
"""The sign in button has the proper wording."""
358
- actual = self.ui.login_button.get_label()
359
+ actual = self.ui.login_button.get_label().decode('utf8')
360
self.assertEqual(gui.LOGIN_BUTTON_LABEL, actual)
362
def test_join_ok_button_does_nothing_if_clicked_but_disabled(self):
364
"""When captcha was retrieved after error, the warning is removed."""
365
self.ui.on_captcha_generation_error(APP_NAME, error=self.error)
366
self.ui.on_captcha_generated(app_name=APP_NAME, captcha_id=CAPTCHA_ID)
367
- self.assertEqual(self.ui.warning_label.get_text(), '')
368
+ self.assertEqual(self.ui.warning_label.get_text().decode('utf8'), '')
371
class NoTermsAndConditionsTestCase(UbuntuSSOClientTestCase):
372
@@ -953,12 +955,13 @@
374
def test_tc_button_has_the_proper_wording(self):
375
"""Terms & Conditions has the proper wording."""
376
- self.assertEqual(self.ui.tc_button.get_label(), gui.TC_BUTTON)
377
+ self.assertEqual(self.ui.tc_button.get_label().decode('utf8'),
380
def test_tc_has_no_help_text(self):
381
"""The help text is removed."""
382
self.ui.on_tc_browser_notify_load_status(self.browser)
383
- self.assertEqual('', self.ui.help_label.get_text())
384
+ self.assertEqual('', self.ui.help_label.get_text().decode('utf8'))
386
def test_tc_browser_opens_the_proper_url(self):
387
"""Terms & Conditions browser shows the proper uri."""
388
@@ -1115,8 +1118,8 @@
390
def test_help_label_display_correct_wording(self):
391
"""The help_label display VERIFY_EMAIL_LABEL."""
392
- msg = 'help_label must read "%s" (got "%s" instead).'
393
- actual = self.ui.help_label.get_label()
394
+ msg = 'help_label must read %r (got %r instead).'
395
+ actual = self.ui.help_label.get_label().decode('utf8')
396
expected = gui.VERIFY_EMAIL_LABEL % {'app_name': APP_NAME,
398
self.assertEqual(expected, actual, msg % (expected, actual))
399
@@ -1160,7 +1163,7 @@
400
"""On email validated the help text is not removed."""
401
self.ui.on_email_validated(app_name=APP_NAME, email=EMAIL)
402
self.assertEqual(self.ui.verify_email_vbox.help_text,
403
- self.ui.help_label.get_label())
404
+ self.ui.help_label.get_label().decode('utf8'))
406
def test_on_email_validation_error_verify_email_is_shown(self):
407
"""On email validation error, the verify_email page is shown."""
408
@@ -1186,16 +1189,16 @@
409
def test_success_label_is_correct(self):
410
"""The success message is correct."""
411
self.assertEqual(gui.SUCCESS % {'app_name': APP_NAME},
412
- self.ui.success_vbox.label.get_text())
413
- markup = self.ui.success_vbox.label.get_label()
414
+ self.ui.success_vbox.label.get_text().decode('utf8'))
415
+ markup = self.ui.success_vbox.label.get_label().decode('utf8')
416
self.assertTrue('<span size="x-large">' in markup)
417
self.assertTrue(self.ui.app_name in markup)
419
def test_error_label_is_correct(self):
420
"""The error message is correct."""
421
self.assertEqual(gui.ERROR,
422
- self.ui.error_vbox.label.get_text())
423
- markup = self.ui.error_vbox.label.get_label()
424
+ self.ui.error_vbox.label.get_text().decode('utf8'))
425
+ markup = self.ui.error_vbox.label.get_label().decode('utf8')
426
self.assertTrue('<span size="x-large">' in markup)
428
def test_on_finish_close_button_clicked_closes_window(self):
429
@@ -1346,7 +1349,7 @@
430
"""Password help text is correctly displayed."""
431
self.assertTrue(self.ui.password_help_label.get_property('visible'),
432
'password help text is visible.')
433
- self.assertEqual(self.ui.password_help_label.get_text(),
434
+ self.assertEqual(self.ui.password_help_label.get_text().decode('utf8'),
436
self.assertNotIn('register_user', self.ui.backend._called)
438
@@ -1436,16 +1439,16 @@
440
def test_initial_text_for_header_label(self):
441
"""The header must have the correct text when logging in."""
442
- msg = 'Text for the header must be "%s" (got "%s" instead).'
443
+ msg = 'Text for the header must be %r (got %r instead).'
444
expected = gui.LOGIN_HEADER_LABEL % {'app_name': APP_NAME}
445
- actual = self.ui.header_label.get_text()
446
+ actual = self.ui.header_label.get_text().decode('utf8')
447
self.assertEqual(expected, actual, msg % (expected, actual))
449
def test_initial_text_for_help_label(self):
450
"""The help must have the correct text at startup."""
451
- msg = 'Text for the help must be "%s" (got "%s" instead).'
452
+ msg = 'Text for the help must be %r (got %r instead).'
453
expected = gui.CONNECT_HELP_LABEL % {'app_name': APP_NAME}
454
- actual = self.ui.help_label.get_text()
455
+ actual = self.ui.help_label.get_text().decode('utf8')
456
self.assertEqual(expected, actual, msg % (expected, actual))
458
def test_entries_are_packed_to_ui_for_login(self):
459
@@ -1628,23 +1631,23 @@
461
def test_forgotten_password_button_has_the_proper_wording(self):
462
"""The forgotten_password_button has the proper wording."""
463
- self.assertEqual(self.ui.forgotten_password_button.get_label(),
464
- gui.FORGOTTEN_PASSWORD_BUTTON)
465
+ actual = self.ui.forgotten_password_button.get_label()
466
+ self.assertEqual(actual.decode('utf8'), gui.FORGOTTEN_PASSWORD_BUTTON)
468
def test_on_forgotten_password_button_clicked_help_text(self):
469
"""Clicking forgotten_password_button the help is properly changed."""
470
wanted = gui.REQUEST_PASSWORD_TOKEN_LABEL % {'app_name': APP_NAME}
471
- self.assertEqual(self.ui.help_label.get_text(), wanted)
472
+ self.assertEqual(self.ui.help_label.get_text().decode('utf8'), wanted)
474
def test_on_forgotten_password_button_clicked_header_label(self):
475
"""Clicking forgotten_password_button the title is properly changed."""
476
- self.assertEqual(self.ui.header_label.get_text(),
477
+ self.assertEqual(self.ui.header_label.get_text().decode('utf8'),
480
def test_on_forgotten_password_button_clicked_ok_button(self):
481
"""Clicking forgotten_password_button the ok button reads 'Next'."""
482
- self.assertEqual(self.ui.request_password_token_ok_button.get_label(),
484
+ actual = self.ui.request_password_token_ok_button.get_label()
485
+ self.assertEqual(actual.decode('utf8'), gui.NEXT)
487
def test_on_forgotten_password_button_clicked_morphs_window(self):
488
"""Clicking forgotten_password_button the proper page is shown."""
489
@@ -1691,7 +1694,7 @@
490
self.click_request_password_token_with_valid_data()
491
self.ui.on_password_reset_token_sent(app_name=APP_NAME, email=EMAIL)
493
- self.assertEqual(self.ui.help_label.get_text(),
494
+ self.assertEqual(self.ui.help_label.get_text().decode('utf8'),
495
gui.SET_NEW_PASSWORD_LABEL % {'email': EMAIL})
497
def test_on_password_reset_token_sent_ok_button(self):
498
@@ -1699,8 +1702,8 @@
499
self.click_request_password_token_with_valid_data()
500
self.ui.on_password_reset_token_sent(app_name=APP_NAME, email=EMAIL)
502
- self.assertEqual(self.ui.set_new_password_ok_button.get_label(),
503
- gui.RESET_PASSWORD)
504
+ actual = self.ui.set_new_password_ok_button.get_label()
505
+ self.assertEqual(actual.decode('utf8'), gui.RESET_PASSWORD)
507
def test_on_password_reset_error_shows_login_page(self):
508
"""When reset token wasn't successfuly sent the login page is shown."""
509
@@ -1872,8 +1875,8 @@
510
"""Password help text is correctly displayed."""
511
visible = self.ui.reset_password_help_label.get_property('visible')
512
self.assertTrue(visible, 'password help text is visible.')
513
- self.assertEqual(self.ui.reset_password_help_label.get_text(),
515
+ actual = self.ui.reset_password_help_label.get_text()
516
+ self.assertEqual(actual.decode('utf8'), gui.PASSWORD_HELP)
517
self.assertNotIn('set_new_password', self.ui.backend._called)
519
def test_warning_is_shown_if_password_mismatch(self):
520
@@ -1951,7 +1954,7 @@
521
"""Callbacks do nothing but logging when app_name doesn't match."""
522
mismatch_app_name = self.ui.app_name * 2
523
for method in self.ui._signals.itervalues():
524
- msgs = ('ignoring', method.__name__, mismatch_app_name)
525
+ msgs = ('ignoring', method.__name__, repr(mismatch_app_name))
526
method(mismatch_app_name, 'dummy')
527
self.assertTrue(self.memento.check(logging.INFO, *msgs))
528
self.memento.records = []
529
@@ -2068,7 +2071,8 @@
531
def test_help_text_is_used(self):
532
"""The passed help_text is used."""
533
- self.assertEqual(self.ui.help_label.get_text(), HELP_TEXT)
534
+ self.assertEqual(self.ui.help_label.get_text().decode('utf8'),
538
class ReturnCodeTestCase(UbuntuSSOClientTestCase):
539
@@ -2087,7 +2091,7 @@
540
def test_every_cancel_calls_proper_callback(self):
541
"""When any cancel button is clicked, USER_CANCELLATION is called."""
542
self.patch(self.ui.backend, 'disconnect_from_signal', lambda *a: None)
543
- msg = 'USER_CANCELLATION should be returned when "%s" is clicked.'
544
+ msg = 'USER_CANCELLATION should be returned when %r is clicked.'
545
buttons = filter(lambda name: 'cancel_button' in name, self.ui.widgets)
547
widget = getattr(self.ui, name)
549
=== modified file 'ubuntu_sso/keyring/tests/test_linux.py'
550
--- old/ubuntu_sso/keyring/tests/test_linux.py 2012-01-26 15:34:16 +0000
551
+++ new/ubuntu_sso/keyring/tests/test_linux.py 2012-02-16 22:09:44 +0000
554
from ubuntu_sso import keyring as common_keyring
555
from ubuntu_sso.keyring import linux as keyring
556
-from ubuntu_sso.tests import APP_NAME
559
class MockItem(object):
561
sample_creds = {"name": "sample creds name"}
562
kr = keyring.Keyring()
563
self.patch(keyring, "get_token_name", keyring.get_old_token_name)
564
- yield kr.set_credentials(APP_NAME, sample_creds)
565
+ yield kr.set_credentials("app name", sample_creds)
567
- result = yield kr.get_credentials(APP_NAME)
568
+ result = yield kr.get_credentials("app name")
569
self.assertEqual(result, sample_creds)
573
=== modified file 'ubuntu_sso/main/__init__.py'
574
--- old/ubuntu_sso/main/__init__.py 2012-02-11 01:51:57 +0000
575
+++ new/ubuntu_sso/main/__init__.py 2012-02-16 21:58:31 +0000
577
def CredentialsFound(self, app_name, credentials):
578
"""Signal thrown when the credentials are found."""
580
- logger.info('%s: emitting CredentialsFound with app_name "%s".',
581
+ logger.info('%s: emitting CredentialsFound with app_name %r.',
582
self.__class__.__name__, app_name)
583
self.proxy.CredentialsFound(app_name, credentials)
586
=== modified file 'ubuntu_sso/main/tests/test_common.py'
587
--- old/ubuntu_sso/main/tests/test_common.py 2012-02-10 17:18:22 +0000
588
+++ new/ubuntu_sso/main/tests/test_common.py 2012-02-16 22:06:06 +0000
590
@defer.inlineCallbacks
592
yield super(CredentialsManagementOpsTestCase, self).setUp()
593
- self.args = dict((k, str(v)) for k, v in self.base_args.iteritems())
594
+ self.args = dict(self.base_args)
595
+ self.args[WINDOW_ID_KEY] = str(self.args[WINDOW_ID_KEY])
596
self.cred_args = self.base_args.copy()
598
def test_register(self):
599
@@ -955,12 +956,16 @@
600
class CredentialsManagementSignalsTestCase(CredentialsManagementTestCase):
601
"""Tests for the CredentialsManagement DBus signals."""
603
+ def assert_signal_logged(self, signal, *args):
604
+ """Check that signal info was properly logged."""
605
+ signal(APP_NAME, *args)
606
+ msgs = [self.obj.__class__.__name__,
607
+ signal.__name__, repr(APP_NAME)]
608
+ self.assertTrue(self.memento.check_info(*msgs))
610
def test_credentials_found(self):
611
"""The CredentialsFound signal."""
612
- self.obj.CredentialsFound(APP_NAME, TOKEN)
613
- msgs = (self.obj.__class__.__name__,
614
- self.obj.CredentialsFound.__name__, APP_NAME)
615
- self.assertTrue(self.memento.check_info(*msgs))
616
+ self.assert_signal_logged(self.obj.CredentialsFound, TOKEN)
618
msg = 'credentials must not be logged (found %r in log).'
619
for val in TOKEN.itervalues():
620
@@ -968,24 +973,15 @@
622
def test_credentials_not_found(self):
623
"""The CredentialsNotFound signal."""
624
- self.obj.CredentialsNotFound(APP_NAME)
625
- msgs = (self.obj.__class__.__name__,
626
- self.obj.CredentialsNotFound.__name__, APP_NAME)
627
- self.assertTrue(self.memento.check_info(*msgs))
628
+ self.assert_signal_logged(self.obj.CredentialsNotFound)
630
def test_credentials_cleared(self):
631
"""The CredentialsCleared signal."""
632
- self.obj.CredentialsCleared(APP_NAME)
633
- msgs = (self.obj.__class__.__name__,
634
- self.obj.CredentialsCleared.__name__, APP_NAME)
635
- self.assertTrue(self.memento.check_info(*msgs))
636
+ self.assert_signal_logged(self.obj.CredentialsCleared)
638
def test_credentials_stored(self):
639
"""The CredentialsStored signal."""
640
- self.obj.CredentialsStored(APP_NAME)
641
- msgs = (self.obj.__class__.__name__,
642
- self.obj.CredentialsStored.__name__, APP_NAME)
643
- self.assertTrue(self.memento.check_info(*msgs))
644
+ self.assert_signal_logged(self.obj.CredentialsStored)
646
def test_credentials_error(self):
647
"""The CredentialsError signal."""
648
@@ -993,15 +989,12 @@
649
self.obj.CredentialsError(APP_NAME, error)
650
msgs = (self.obj.__class__.__name__,
651
self.obj.CredentialsError.__name__,
652
- APP_NAME, str(error))
653
+ repr(APP_NAME), repr(error))
654
self.assertTrue(self.memento.check_error(*msgs))
656
def test_authorization_denied(self):
657
"""The AuthorizationDenied signal."""
658
- self.obj.AuthorizationDenied(APP_NAME)
659
- msgs = (self.obj.__class__.__name__,
660
- self.obj.AuthorizationDenied.__name__, APP_NAME)
661
- self.assertTrue(self.memento.check_info(*msgs))
662
+ self.assert_signal_logged(self.obj.AuthorizationDenied)
665
class UbuntuSSOServiceTestCase(BaseTestCase):
667
=== modified file 'ubuntu_sso/qt/__init__.py'
668
--- old/ubuntu_sso/qt/__init__.py 2012-02-09 18:28:40 +0000
669
+++ new/ubuntu_sso/qt/__init__.py 2012-02-17 17:15:57 +0000
672
"""The Qt graphical interface for the Ubuntu Single Sign On Client."""
680
ERROR_ALL = '__all__'
681
ERROR_MESSAGE = 'message'
682
-LOCAL_FOLDERS_TITLE = _("Syncing your computer with the cloud")
683
-LOCAL_FOLDERS_SPACE_HEADER = _("Space (%s)")
684
-LOCAL_FOLDERS_OFFER_LABEL = _("The folders you have selected to sync "
685
- "take over your %(quota)s space. You can remove some folders or add "
686
- "some extra space")
687
-LOCAL_FOLDERS_CALCULATING = _("Calculating")
691
# Based on the gtk implementation
693
=== modified file 'ubuntu_sso/qt/current_user_sign_in_page.py'
694
--- old/ubuntu_sso/qt/current_user_sign_in_page.py 2012-02-13 20:27:48 +0000
695
+++ new/ubuntu_sso/qt/current_user_sign_in_page.py 2012-02-17 17:16:26 +0000
698
"""Page to allow the user to login into Ubuntu Single Sign On."""
702
from PyQt4 import QtGui, QtCore
703
from twisted.internet import defer
706
from ubuntu_sso.qt.gui import SSOWizardPage
707
from ubuntu_sso.logger import setup_logging
708
from ubuntu_sso.utils.ui import (
711
FORGOTTEN_PASSWORD_BUTTON,
714
FORGOTTEN_PASSWORD_LINK_STYLE = '<a href="#">{forgotten_text}</a>'
718
logger = setup_logging('ubuntu_sso.current_user_sign_in_page')
723
def initializePage(self):
724
"""Setup UI details."""
725
- self.setButtonText(QtGui.QWizard.CancelButton,
727
+ self.setButtonText(QtGui.QWizard.CancelButton, CANCEL_BUTTON)
728
# Layout without custom button 1,
729
# without finish button
730
self.wizard().setButtonLayout([
732
=== modified file 'ubuntu_sso/qt/network_detection_page.py'
733
--- old/ubuntu_sso/qt/network_detection_page.py 2012-02-13 20:27:48 +0000
734
+++ new/ubuntu_sso/qt/network_detection_page.py 2012-02-17 17:16:42 +0000
737
"""Pages from SSO."""
742
from twisted.internet import defer
743
from PyQt4 import QtGui
745
from ubuntu_sso import networkstate
747
from ubuntu_sso.qt.ui import network_detection_ui
750
+from ubuntu_sso.utils.ui import (
751
+ CLOSE_AND_SETUP_LATER,
752
+ NETWORK_DETECTION_TITLE,
757
class NetworkDetectionPage(QtGui.QWizardPage):
760
def __init__(self, banner_pixmap=None, parent=None):
761
super(NetworkDetectionPage, self).__init__(parent)
762
- self.setTitle(_("Network detection"))
763
+ self.setTitle(NETWORK_DETECTION_TITLE)
764
self.ui = network_detection_ui.Ui_Form()
765
self.ui.setupUi(self)
766
if banner_pixmap is not None:
768
"""Set UI details."""
769
self.wizard()._next_id = None
771
- self.setButtonText(QtGui.QWizard.CustomButton1, _("Try again"))
772
+ self.setButtonText(QtGui.QWizard.CustomButton1, TRY_AGAIN_BUTTON)
773
self.setButtonText(QtGui.QWizard.CancelButton,
774
- _("Close window and set up later"))
775
+ CLOSE_AND_SETUP_LATER)
776
self.wizard().setButtonLayout([
777
QtGui.QWizard.Stretch,
778
QtGui.QWizard.CustomButton1,
780
=== modified file 'ubuntu_sso/qt/setup_account_page.py'
781
--- old/ubuntu_sso/qt/setup_account_page.py 2012-02-13 20:27:48 +0000
782
+++ new/ubuntu_sso/qt/setup_account_page.py 2012-02-17 17:17:56 +0000
784
is_min_required_password,
792
self.set_up_button.clicked.connect(self.set_next_validation)
793
self.set_up_button.setEnabled(False)
795
- self.ui.name_label.setText(NAME)
796
+ self.ui.name_label.setText(NAME_ENTRY)
797
self.ui.email_label.setText(EMAIL)
798
self.ui.confirm_email_label.setText(RETYPE_EMAIL)
799
self.ui.password_label.setText(PASSWORD)
801
#pylint: enable=C0103
803
def _set_translated_strings(self):
804
- """Set the different gettext translated strings."""
805
+ """Set the strings."""
806
logger.debug('SetUpAccountPage._set_translated_strings')
807
# set the translated string
808
self.ui.name_label.setText(NAME_ENTRY)
810
=== modified file 'ubuntu_sso/qt/sign_in_page.py'
811
--- old/ubuntu_sso/qt/sign_in_page.py 2012-02-13 20:27:48 +0000
812
+++ new/ubuntu_sso/qt/sign_in_page.py 2012-02-17 17:18:09 +0000
815
"""Page to allow the user to sign in."""
819
from PyQt4 import QtGui, QtCore
821
from ubuntu_sso.qt.gui import SSOWizardPage
822
from ubuntu_sso.logger import setup_logging
823
from ubuntu_sso.utils.ui import (
824
+ CLOSE_AND_SETUP_LATER,
825
EXISTING_ACCOUNT_CHOICE_BUTTON,
826
SET_UP_ACCOUNT_CHOICE_BUTTON,
831
logger = setup_logging('ubuntu_sso.sing_in_page')
836
def initializePage(self):
837
"""Setup UI details."""
838
- self.ui.cancel_button.setText(_("Close window and setup later"))
839
+ self.ui.cancel_button.setText(CLOSE_AND_SETUP_LATER)
840
self.ui.cancel_button.clicked.connect(self.singInCanceled.emit)
841
# Layout without custom button 1,
842
# without finish button
844
=== modified file 'ubuntu_sso/qt/tests/test_setup_account.py'
845
--- old/ubuntu_sso/qt/tests/test_setup_account.py 2012-02-10 21:09:38 +0000
846
+++ new/ubuntu_sso/qt/tests/test_setup_account.py 2012-02-17 17:24:10 +0000
848
self.assertFalse(self.ui.captcha_received)
851
- self.assertEqual(self.ui.ui.name_label.text(), setup_account_page.NAME)
852
+ self.assertEqual(self.ui.ui.name_label.text(),
853
+ setup_account_page.NAME_ENTRY)
854
self.assertEqual(self.ui.ui.email_label.text(),
855
setup_account_page.EMAIL)
856
self.assertEqual(self.ui.ui.confirm_email_label.text(),
858
=== modified file 'ubuntu_sso/tests/__init__.py'
859
--- old/ubuntu_sso/tests/__init__.py 2012-02-10 17:18:22 +0000
860
+++ new/ubuntu_sso/tests/__init__.py 2012-02-17 17:18:34 +0000
863
from ubuntu_sso.keyring import get_token_name
865
-APP_NAME = u'The Super App!'
866
+APP_NAME = u'I ♥ Ubuntu'
867
CAPTCHA_ID = u'test ñiña'
868
CAPTCHA_PATH = os.path.abspath(os.path.join(os.curdir, 'ubuntu_sso', 'tests',
869
'files', 'captcha.png'))
870
CAPTCHA_SOLUTION = u'william Byrd ñandú'
871
EMAIL = u'test@example.com'
872
-EMAIL_TOKEN = u'B2Pgtf'
873
+EMAIL_TOKEN = u'B2P☺ gtf'
874
GTK_GUI_EXE = 'ubuntu-sso-login-gtk'
875
-HELP_TEXT = """Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sed
876
-lorem nibh. Suspendisse gravida nulla non nunc suscipit pulvinar tempus ut
877
-augue. Morbi consequat, ligula a elementum pretium, dolor nulla tempus metus,
878
-sed viverra nisi risus non velit."""
879
-NAME = u'Juanito Pérez'
880
-PASSWORD = u'h3lloWorld'
881
+HELP_TEXT = u'☛ Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' \
882
+'Nam sed lorem nibh. Suspendisse gravida nulla non nunc suscipit pulvinar ' \
883
+'tempus ut augue. Morbi consequat, ligula a elementum pretium, ' \
884
+'dolor nulla tempus metus, sed viverra nisi risus non velit.'
885
+NAME = u'Juanito ☀ Pérez'
886
+PASSWORD = u'h3lloWorld☑ '
887
PING_URL = u'http://localhost/ping-me/'
888
POLICY_URL = u'http://localhost/policy/'
889
RESET_PASSWORD_TOKEN = u'8G5Wtq'
891
=== modified file 'ubuntu_sso/utils/runner/glib.py'
892
--- old/ubuntu_sso/utils/runner/glib.py 2012-02-10 17:03:56 +0000
893
+++ new/ubuntu_sso/utils/runner/glib.py 2012-02-17 17:32:30 +0000
895
GLib.SpawnFlags.STDOUT_TO_DEV_NULL | \
896
GLib.SpawnFlags.STDERR_TO_DEV_NULL
901
+ if isinstance(arg, unicode):
902
+ arg = arg.encode('utf-8')
903
+ if not isinstance(arg, basestring):
905
+ bytes_args.append(arg)
908
- pid, _, _, _ = GLib.spawn_async(argv=args, flags=flags)
909
+ pid, _, _, _ = GLib.spawn_async(argv=bytes_args, flags=flags)
910
except GLib.GError, e:
914
=== modified file 'ubuntu_sso/utils/ui.py'
915
--- old/ubuntu_sso/utils/ui.py 2012-02-13 20:27:48 +0000
916
+++ new/ubuntu_sso/utils/ui.py 2012-02-17 17:19:38 +0000
919
from ubuntu_sso.logger import setup_logging
922
+gettext.install('ubuntu-sso-client', unicode=True)
923
logger = setup_logging('ubuntu_sso.utils.ui')
926
-gettext.textdomain('ubuntu-sso-client')
928
+# Undefined variable '_', pylint: disable=E0602
930
# all the text that is used in the gui
931
AGREE_TO_PRIVACY_POLICY = _('By signing up to {app_name} you agree to '
933
AGREE_TO_TERMS = _('By signing up to {app_name} you agree to '
934
'our {terms_and_conditions}')
935
AGREE_TO_TERMS_AND_PRIVACY_POLICY = AGREE_TO_TERMS + _(' and {privacy_policy}')
936
+CANCEL_BUTTON = _('Cancel')
937
CAPTCHA_SOLUTION_ENTRY = _('Type the characters above')
938
CAPTCHA_LOAD_ERROR = _('There was a problem getting the captcha, '
940
CAPTCHA_RELOAD_TOOLTIP = _('Reload')
941
CAPTCHA_REQUIRED_ERROR = _('The captcha is a required field')
942
+CLOSE_AND_SETUP_LATER = _('Close window and setup later')
943
CONGRATULATIONS = _("Congratulations, {app_name} is installed!")
944
PROXY_CREDS_DIALOG_TITLE = _('Add proxy settings')
945
PROXY_CREDS_HEADER = _('You are connecting through a proxy.')
947
LOGIN_HEADER_LABEL = _('Connect to %(app_name)s')
948
LOGIN_PASSWORD_ENTRY = _('Password')
949
LOGIN_PASSWORD_LABEL = LOGIN_PASSWORD_ENTRY
951
NAME_ENTRY = _('Name')
952
NAME_INVALID = _('The name must not be empty.')
954
+NETWORK_DETECTION_TITLE = _('Network detection')
955
ONE_MOMENT_PLEASE = _('One moment please...')
956
PASSWORD = _("Create a password")
957
PASSWORD_CHANGED = _('Your password was successfully changed.')
959
YES_TO_TC = _('I agree with the %(app_name)s terms and conditions')
960
YES_TO_UPDATES = _('Yes! Email me %(app_name)s tips and updates.')
962
+# pylint: enable=E0602
965
def get_password_strength(password):
966
"""Return the strength of the password.