Merge lp:~nataliabidart/ubuntu-sso-client/fix-933632 into lp:ubuntu-sso-client

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 884
Merged at revision: 880
Proposed branch: lp:~nataliabidart/ubuntu-sso-client/fix-933632
Merge into: lp:ubuntu-sso-client
Diff against target: 1225 lines (+294/-189)
21 files modified
setup.py (+0/-39)
ubuntu_sso/credentials.py (+3/-1)
ubuntu_sso/gtk/gui.py (+14/-16)
ubuntu_sso/gtk/tests/test_gui.py (+57/-53)
ubuntu_sso/keyring/tests/test_linux.py (+2/-3)
ubuntu_sso/main/__init__.py (+1/-1)
ubuntu_sso/main/tests/test_common.py (+15/-22)
ubuntu_sso/qt/__init__.py (+0/-10)
ubuntu_sso/qt/current_user_sign_in_page.py (+2/-4)
ubuntu_sso/qt/gui.py (+0/-2)
ubuntu_sso/qt/network_detection_page.py (+8/-8)
ubuntu_sso/qt/setup_account_page.py (+2/-3)
ubuntu_sso/qt/sign_in_page.py (+2/-4)
ubuntu_sso/qt/tests/test_setup_account.py (+2/-1)
ubuntu_sso/tests/__init__.py (+8/-8)
ubuntu_sso/utils/runner/glib.py (+11/-2)
ubuntu_sso/utils/runner/tests/test_glib.py (+132/-0)
ubuntu_sso/utils/runner/tests/test_qt.py (+9/-1)
ubuntu_sso/utils/runner/tests/test_runner.py (+9/-7)
ubuntu_sso/utils/runner/tx.py (+9/-1)
ubuntu_sso/utils/ui.py (+8/-3)
To merge this branch: bzr merge lp:~nataliabidart/ubuntu-sso-client/fix-933632
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Eric Casteleijn (community) Approve
Review via email: mp+93641@code.launchpad.net

Commit message

- Make gettext return unicode strings. Also, transform arguments passed to
  the GLib spawnner to bytes (LP: #933632).

To post a comment you must log in.
Revision history for this message
Eric Casteleijn (thisfred) wrote :

Looks good, great that the tests use unicode characters, nice incremental refactorings.

review: Approve
Revision history for this message
Roberto Alsina (ralsina) wrote :

Looks good to me!

review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (72.3 KiB)

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

*** Running GTK test suite for ubuntu_sso ***
twisted.trial.unittest
  TestCase
    runTest ... [OK]
ubuntu_sso.keyring.tests.test_common
  TestGetHostname
    test_get_hostname ... [OK]
    test_get_hostname_uses_filesystem_encoding ... [OK]
  TestTokenNameBuilder
    test_get_complex_token_name_for_app_name ... [OK]
    test_get_complex_token_name_for_hostname ... [OK]
    test_get_simple_token_name ... [OK]
    test_get_unicode_appname_token_name ... [OK]
    test_get_utf8_hostname_token_name ... [OK]
twisted.trial.unittest
  TestCase
    runTest ... [OK]
ubuntu_sso.keyring.tests.test_linux
  TestKeyring
    test_delete_credentials ... [OK]
    test_get_credentials ... [OK]
    test_get_credentials_migrating_token ... [OK]
    test_get_old_cred_found ... [OK]
    test_get_old_cred_found_but_not_asked_for ... [OK]
    test_get_old_cred_not_found ... [OK]
    test_set_credentials ... [OK]
ubuntu_sso.networkstate.tests.test_linux
  NetworkManagerStateErrorsTestCase
    test_dbus_problem ... [OK]
    test_nm_not_running ... [OK]
  NetworkManagerStateTestCase
    test_nm_connecting_then_offline ... [OK]
    test_nm_connecting_then_offline_old ... [OK]
    test_nm_connecting_then_online ... [OK]
    test_nm_connecting_then_online_old ... [OK]
    test_nm_offline ... [OK]
    test_nm_offline_local ... [OK]
    test_nm_offline_old ... [OK]
    test_nm_offline_site ... [OK]
    test_nm_online_global ... [OK]
    test_nm_online_old ... [OK]
ubuntu_sso.tests
  TestCase
    runTest ... [OK]
ubuntu_sso.networkstate.tests.test_linux
  TestConnection
    test_is_machine_connected_nm_state_connected_global ... [OK]
    test_is_machine_connected_nm_state_connected_old ... [OK]
    test_is_machine_defer_error ... [OK]
    test_is_machine_disconnected_nm_state_asleep ... ...

Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (132.7 KiB)

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

*** Running GTK test suite for ubuntu_sso ***
twisted.trial.unittest
  TestCase
    runTest ... [OK]
ubuntu_sso.keyring.tests.test_common
  TestGetHostname
    test_get_hostname ... [OK]
    test_get_hostname_uses_filesystem_encoding ... [OK]
  TestTokenNameBuilder
    test_get_complex_token_name_for_app_name ... [OK]
    test_get_complex_token_name_for_hostname ... [OK]
    test_get_simple_token_name ... [OK]
    test_get_unicode_appname_token_name ... [OK]
    test_get_utf8_hostname_token_name ... [OK]
twisted.trial.unittest
  TestCase
    runTest ... [OK]
ubuntu_sso.keyring.tests.test_linux
  TestKeyring
    test_delete_credentials ... [OK]
    test_get_credentials ... [OK]
    test_get_credentials_migrating_token ... [OK]
    test_get_old_cred_found ... [OK]
    test_get_old_cred_found_but_not_asked_for ... [OK]
    test_get_old_cred_not_found ... [OK]
    test_set_credentials ... [OK]
ubuntu_sso.networkstate.tests.test_linux
  NetworkManagerStateErrorsTestCase
    test_dbus_problem ... [OK]
    test_nm_not_running ... [OK]
  NetworkManagerStateTestCase
    test_nm_connecting_then_offline ... [OK]
    test_nm_connecting_then_offline_old ... [OK]
    test_nm_connecting_then_online ... [OK]
    test_nm_connecting_then_online_old ... [OK]
    test_nm_offline ... [OK]
    test_nm_offline_local ... [OK]
    test_nm_offline_old ... [OK]
    test_nm_offline_site ... [OK]
    test_nm_online_global ... [OK]
    test_nm_online_old ... [OK]
ubuntu_sso.tests
  TestCase
    runTest ... [OK]
ubuntu_sso.networkstate.tests.test_linux
  TestConnection
    test_is_machine_connected_nm_state_connected_global ... [OK]
    test_is_machine_connected_nm_state_connected_old ... [OK]
    test_is_machine_defer_error ... [OK]
    test_is_machine_disconnected_nm_state_asleep ... ...

884. By Natalia Bidart

Adapting mock so it works with LANG=C.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'setup.py'
--- setup.py 2012-02-14 20:49:45 +0000
+++ setup.py 2012-02-18 14:14:18 +0000
@@ -153,11 +153,6 @@
153153
154 def run(self):154 def run(self):
155 """Execute the command."""155 """Execute the command."""
156 # pylint: disable=W0703
157 try:
158 self._wrapuic()
159 except Exception, e:
160 self.warn("Error wrapping uic to use gettext: %s" % e)
161 basepath = os.path.join('data', 'qt')156 basepath = os.path.join('data', 'qt')
162 # TODO: build the resource files so that we can include them157 # TODO: build the resource files so that we can include them
163 #self.build_rc(os.path.join(basepath, 'icons_rc.py'),158 #self.build_rc(os.path.join(basepath, 'icons_rc.py'),
@@ -172,40 +167,6 @@
172167
173 build_extra.build_extra.run(self)168 build_extra.build_extra.run(self)
174169
175 # pylint: disable=E1002
176 _wrappeduic = False
177
178 @classmethod
179 def _wrapuic(cls):
180 """Wrap uic to use gettext's _() in place of tr()"""
181 if cls._wrappeduic:
182 return
183
184 from PyQt4.uic.Compiler import compiler, qtproxies, indenter
185
186 # pylint: disable=C0103
187 class _UICompiler(compiler.UICompiler):
188 """Speciallized compiler for qt .ui files."""
189 def createToplevelWidget(self, classname, widgetname):
190 o = indenter.getIndenter()
191 o.level = 0
192 o.write('from gettext import gettext as _')
193 return super(_UICompiler, self).createToplevelWidget(classname,
194 widgetname)
195 compiler.UICompiler = _UICompiler
196
197 class _i18n_string(qtproxies.i18n_string):
198 """Provide a translated text."""
199
200 def __str__(self):
201 return "_('%s')" % self.string.encode('string-escape')
202
203 qtproxies.i18n_string = _i18n_string
204
205 cls._wrappeduic = True
206 # pylint: enable=C0103
207 # pylint: enable=E1002
208
209170
210class SSOClean(DistUtilsExtra.auto.clean_build_tree):171class SSOClean(DistUtilsExtra.auto.clean_build_tree):
211 """Class to clean up after the build."""172 """Class to clean up after the build."""
212173
=== modified file 'ubuntu_sso/credentials.py'
--- ubuntu_sso/credentials.py 2012-02-11 19:25:01 +0000
+++ ubuntu_sso/credentials.py 2012-02-18 14:14:18 +0000
@@ -148,7 +148,9 @@
148 value = getattr(self, arg)148 value = getattr(self, arg)
149 if value:149 if value:
150 args.append('--%s' % arg)150 args.append('--%s' % arg)
151 args.append("%s" % str(value))151 if not isinstance(value, basestring):
152 value = str(value)
153 args.append(value)
152154
153 if login_only:155 if login_only:
154 args.append('--login_only')156 args.append('--login_only')
155157
=== modified file 'ubuntu_sso/gtk/gui.py'
--- ubuntu_sso/gtk/gui.py 2012-02-11 19:25:01 +0000
+++ ubuntu_sso/gtk/gui.py 2012-02-18 14:14:18 +0000
@@ -111,6 +111,7 @@
111# To be replaced by values from the theme (LP: #616526)111# To be replaced by values from the theme (LP: #616526)
112HELP_TEXT_COLOR = parse_color("#bfbfbf")112HELP_TEXT_COLOR = parse_color("#bfbfbf")
113WARNING_TEXT_COLOR = parse_color("red")113WARNING_TEXT_COLOR = parse_color("red")
114LARGE_MARKUP = u'<span size="x-large">%s</span>'
114115
115116
116def log_call(f):117def log_call(f):
@@ -173,9 +174,9 @@
173174
174 def get_text(self):175 def get_text(self):
175 """Get text only if it's not the label nor empty."""176 """Get text only if it's not the label nor empty."""
176 result = super(LabeledEntry, self).get_text()177 result = super(LabeledEntry, self).get_text().decode('utf8')
177 if result == self.label or result.isspace():178 if result == self.label or result.isspace():
178 result = ''179 result = u''
179 return result180 return result
180181
181 def set_warning(self, warning_msg):182 def set_warning(self, warning_msg):
@@ -209,10 +210,10 @@
209 self._done = False # whether the whole process was completed or not210 self._done = False # whether the whole process was completed or not
210211
211 self.app_name = app_name212 self.app_name = app_name
212 self.app_label = '<b>%s</b>' % self.app_name213 self.app_label = u'<b>%s</b>' % self.app_name
213 self.ping_url = kwargs.get('ping_url', '')214 self.ping_url = kwargs.get('ping_url', u'')
214 self.tc_url = kwargs.get('tc_url', '')215 self.tc_url = kwargs.get('tc_url', u'')
215 self.help_text = kwargs.get('help_text', '')216 self.help_text = kwargs.get('help_text', u'')
216 self.login_only = kwargs.get('login_only', False)217 self.login_only = kwargs.get('login_only', False)
217 window_id = kwargs.get('window_id', 0)218 window_id = kwargs.get('window_id', 0)
218 self.close_callback = kwargs.get('close_callback', NO_OP)219 self.close_callback = kwargs.get('close_callback', NO_OP)
@@ -338,15 +339,14 @@
338 def success_vbox(self):339 def success_vbox(self):
339 """The success page."""340 """The success page."""
340 message = SUCCESS % {'app_name': self.app_name}341 message = SUCCESS % {'app_name': self.app_name}
341 message = '<span size="x-large">%s</span>' % message342 message = LARGE_MARKUP % message
342 self.finish_vbox.label.set_markup(message)343 self.finish_vbox.label.set_markup(message)
343 return self.finish_vbox344 return self.finish_vbox
344345
345 @property346 @property
346 def error_vbox(self):347 def error_vbox(self):
347 """The error page."""348 """The error page."""
348 self.finish_vbox.label.set_markup('<span size="x-large">%s</span>' %349 self.finish_vbox.label.set_markup(LARGE_MARKUP % ERROR)
349 ERROR)
350 return self.finish_vbox350 return self.finish_vbox
351351
352 # helpers352 # helpers
@@ -362,7 +362,7 @@
362 result = f(app_name, *args, **kwargs)362 result = f(app_name, *args, **kwargs)
363 else:363 else:
364 logger.info('%s: ignoring call since received app_name '\364 logger.info('%s: ignoring call since received app_name '\
365 '"%s" (expected "%s")',365 '%r (expected %r)',
366 f.__name__, app_name, self.app_name)366 f.__name__, app_name, self.app_name)
367 return result367 return result
368368
@@ -459,8 +459,7 @@
459459
460 def _set_header(self, header):460 def _set_header(self, header):
461 """Set 'header' as the window title and header."""461 """Set 'header' as the window title and header."""
462 markup = '<span size="x-large">%s</span>'462 self.header_label.set_markup(LARGE_MARKUP % header)
463 self.header_label.set_markup(markup % header)
464 self.window.set_title(self.header_label.get_text()) # avoid markup463 self.window.set_title(self.header_label.get_text()) # avoid markup
465464
466 def _set_current_page(self, current_page, warning_text=None):465 def _set_current_page(self, current_page, warning_text=None):
@@ -792,9 +791,8 @@
792 f = self.backend.register_user791 f = self.backend.register_user
793 error_handler = partial(self._handle_error, f,792 error_handler = partial(self._handle_error, f,
794 self.on_user_registration_error)793 self.on_user_registration_error)
795 f(unicode(self.app_name), email1.decode('utf8'),794 f(self.app_name, self.user_email, self.user_password, name,
796 password1.decode('utf8'), name.decode('utf8'),795 self._captcha_id, captcha_solution,
797 unicode(self._captcha_id), captcha_solution.decode('utf8'),
798 reply_handler=NO_OP, error_handler=error_handler)796 reply_handler=NO_OP, error_handler=error_handler)
799797
800 def on_verify_token_button_clicked(self, *args, **kwargs):798 def on_verify_token_button_clicked(self, *args, **kwargs):
@@ -1035,7 +1033,7 @@
1035 """Captcha image has been generated and is available to be shown."""1033 """Captcha image has been generated and is available to be shown."""
1036 if captcha_id is None:1034 if captcha_id is None:
1037 logger.warning('on_captcha_generated: captcha_id is None for '1035 logger.warning('on_captcha_generated: captcha_id is None for '
1038 'app_name "%s".', app_name)1036 'app_name %r.', app_name)
1039 self._captcha_id = captcha_id1037 self._captcha_id = captcha_id
1040 self._set_captcha_image()1038 self._set_captcha_image()
10411039
10421040
=== modified file 'ubuntu_sso/gtk/tests/test_gui.py'
--- ubuntu_sso/gtk/tests/test_gui.py 2012-02-11 01:51:57 +0000
+++ ubuntu_sso/gtk/tests/test_gui.py 2012-02-18 14:14:18 +0000
@@ -165,7 +165,7 @@
165 tmp = Gdk.RGBA()165 tmp = Gdk.RGBA()
166 assert tmp.parse(gdk_color.to_string())166 assert tmp.parse(gdk_color.to_string())
167167
168 msg = 'Text color must be "%s" (got "%s" instead).'168 msg = 'Text color must be %r (got %r instead).'
169 self.assertEqual(rgba_color, tmp, msg % (rgba_color, tmp))169 self.assertEqual(rgba_color, tmp, msg % (rgba_color, tmp))
170170
171 def assert_backend_called(self, method, *args, **kwargs):171 def assert_backend_called(self, method, *args, **kwargs):
@@ -211,7 +211,7 @@
211 def assert_correct_label(self):211 def assert_correct_label(self):
212 """Check that the entry has the correct label."""212 """Check that the entry has the correct label."""
213 # text content is correct213 # text content is correct
214 msg = 'Text content must be "%s" (got "%s" instead).'214 msg = 'Text content must be %r (got %r instead).'
215 expected = self.label215 expected = self.label
216 actual = super(gui.LabeledEntry, self.entry).get_text()216 actual = super(gui.LabeledEntry, self.entry).get_text()
217 self.assertEqual(expected, actual, msg % (expected, actual))217 self.assertEqual(expected, actual, msg % (expected, actual))
@@ -231,7 +231,7 @@
231231
232 def test_tooltip(self):232 def test_tooltip(self):
233 """Entry have the correct tooltip."""233 """Entry have the correct tooltip."""
234 msg = 'Tooltip must be "%s" (got "%s" instead).'234 msg = 'Tooltip must be %r (got %r instead).'
235 expected = self.label235 expected = self.label
236 actual = self.entry.get_tooltip_text()236 actual = self.entry.get_tooltip_text()
237 # tooltip is correct237 # tooltip is correct
@@ -404,7 +404,7 @@
404404
405 def assert_entries_are_packed_to_ui(self, container_name, entries):405 def assert_entries_are_packed_to_ui(self, container_name, entries):
406 """Every entry is properly packed in the ui 'container_name'."""406 """Every entry is properly packed in the ui 'container_name'."""
407 msg = 'Entry "%s" must be packed in "%s" but is not.'407 msg = 'Entry %r must be packed in %r but is not.'
408 container = getattr(self.ui, container_name)408 container = getattr(self.ui, container_name)
409 for kind in entries:409 for kind in entries:
410 name = '%s_entry' % kind410 name = '%s_entry' % kind
@@ -414,7 +414,7 @@
414414
415 def assert_warnings_visibility(self, visible=False):415 def assert_warnings_visibility(self, visible=False):
416 """Every warning label should be 'visible'."""416 """Every warning label should be 'visible'."""
417 msg = '"%s" should have %sempty content.'417 msg = '%r should have %sempty content.'
418 for name in self.ui.widgets:418 for name in self.ui.widgets:
419 widget = getattr(self.ui, name)419 widget = getattr(self.ui, name)
420 if 'warning' in name:420 if 'warning' in name:
@@ -429,7 +429,7 @@
429 self.assertTrue(label.get_property('visible'))429 self.assertTrue(label.get_property('visible'))
430430
431 # warning content is correct431 # warning content is correct
432 actual = label.get_text()432 actual = label.get_text().decode('utf-8')
433 self.assertEqual(actual, message)433 self.assertEqual(actual, message)
434434
435 # content color is correct435 # content color is correct
@@ -547,7 +547,7 @@
547547
548 def test_initial_text_for_entries(self):548 def test_initial_text_for_entries(self):
549 """Entries have the correct text at startup."""549 """Entries have the correct text at startup."""
550 msg = 'Text for "%s" must be "%s" (got "%s" instead).'550 msg = 'Text for %r must be %r (got %r instead).'
551 for name in self.ui.entries:551 for name in self.ui.entries:
552 entry = getattr(self.ui, name)552 entry = getattr(self.ui, name)
553 expected = getattr(gui.utils.ui, name.upper())553 expected = getattr(gui.utils.ui, name.upper())
@@ -557,14 +557,14 @@
557557
558 def test_entries_activates_default(self):558 def test_entries_activates_default(self):
559 """Entries have the activates default prop set."""559 """Entries have the activates default prop set."""
560 msg = '"%s" must have activates_default set to True.'560 msg = '%r must have activates_default set to True.'
561 for name in self.ui.entries:561 for name in self.ui.entries:
562 entry = getattr(self.ui, name)562 entry = getattr(self.ui, name)
563 self.assertTrue(entry.get_activates_default(), msg % (name,))563 self.assertTrue(entry.get_activates_default(), msg % (name,))
564564
565 def test_password_fields_are_password(self):565 def test_password_fields_are_password(self):
566 """Password fields have the is_password flag set."""566 """Password fields have the is_password flag set."""
567 msg = '"%s" should be a password LabeledEntry instance.'567 msg = '%r should be a password LabeledEntry instance.'
568 passwords = filter(lambda name: 'password' in name,568 passwords = filter(lambda name: 'password' in name,
569 self.ui.entries)569 self.ui.entries)
570 for name in passwords:570 for name in passwords:
@@ -578,7 +578,7 @@
578 def test_cancel_buttons_close_window(self):578 def test_cancel_buttons_close_window(self):
579 """Every cancel button should close the window when clicked."""579 """Every cancel button should close the window when clicked."""
580 self.patch(self.ui.backend, 'disconnect_from_signal', lambda *a: None)580 self.patch(self.ui.backend, 'disconnect_from_signal', lambda *a: None)
581 msg = '"%s" should close the window when clicked.'581 msg = '%r should close the window when clicked.'
582 buttons = filter(lambda name: 'cancel_button' in name or582 buttons = filter(lambda name: 'cancel_button' in name or
583 'close_button' in name, self.ui.widgets)583 'close_button' in name, self.ui.widgets)
584 for name in buttons:584 for name in buttons:
@@ -597,15 +597,16 @@
597 self.ui.finish_success()597 self.ui.finish_success()
598 self.assert_pages_visibility(finish=True)598 self.assert_pages_visibility(finish=True)
599 self.assertEqual(gui.SUCCESS % {'app_name': APP_NAME},599 self.assertEqual(gui.SUCCESS % {'app_name': APP_NAME},
600 self.ui.finish_vbox.label.get_text())600 self.ui.finish_vbox.label.get_text().decode('utf8'))
601 result = self.ui.finish_vbox.label.get_text()601 result = self.ui.finish_vbox.label.get_text().decode('utf8')
602 self.assertTrue(self.ui.app_name in result)602 self.assertTrue(self.ui.app_name in result)
603603
604 def test_finish_error_shows_error_page(self):604 def test_finish_error_shows_error_page(self):
605 """When calling 'finish_error' the error page is shown."""605 """When calling 'finish_error' the error page is shown."""
606 self.ui.finish_error()606 self.ui.finish_error()
607 self.assert_pages_visibility(finish=True)607 self.assert_pages_visibility(finish=True)
608 self.assertEqual(gui.ERROR, self.ui.finish_vbox.label.get_text())608 self.assertEqual(gui.ERROR,
609 self.ui.finish_vbox.label.get_text().decode('utf8'))
609610
610611
611class SetTransientForTestCase(UbuntuSSOClientTestCase):612class SetTransientForTestCase(UbuntuSSOClientTestCase):
@@ -649,9 +650,9 @@
649650
650 def test_initial_text_for_header_label(self):651 def test_initial_text_for_header_label(self):
651 """The header must have the correct text at startup."""652 """The header must have the correct text at startup."""
652 msg = 'Text for the header must be "%s" (got "%s" instead).'653 msg = 'Text for the header must be %r (got %r instead).'
653 expected = gui.JOIN_HEADER_LABEL % {'app_name': APP_NAME}654 expected = gui.JOIN_HEADER_LABEL % {'app_name': APP_NAME}
654 actual = self.ui.header_label.get_text()655 actual = self.ui.header_label.get_text().decode('utf8')
655 # text content is correct656 # text content is correct
656 self.assertEqual(expected, actual, msg % (expected, actual))657 self.assertEqual(expected, actual, msg % (expected, actual))
657658
@@ -670,26 +671,26 @@
670671
671 def test_initial_texts_for_checkbuttons(self):672 def test_initial_texts_for_checkbuttons(self):
672 """Check buttons have the correct text at startup."""673 """Check buttons have the correct text at startup."""
673 msg = 'Text for "%s" must be "%s" (got "%s" instead).'674 msg = 'Text for %r must be %r (got %r instead).'
674 expected = gui.YES_TO_UPDATES % {'app_name': APP_NAME}675 expected = gui.YES_TO_UPDATES % {'app_name': APP_NAME}
675 actual = self.ui.yes_to_updates_checkbutton.get_label()676 actual = self.ui.yes_to_updates_checkbutton.get_label().decode('utf8')
676 self.assertEqual(expected, actual, msg % ('yes_to_updates_checkbutton',677 self.assertEqual(expected, actual, msg % ('yes_to_updates_checkbutton',
677 expected, actual))678 expected, actual))
678 expected = gui.YES_TO_TC % {'app_name': APP_NAME}679 expected = gui.YES_TO_TC % {'app_name': APP_NAME}
679 actual = self.ui.yes_to_tc_checkbutton.get_label()680 actual = self.ui.yes_to_tc_checkbutton.get_label().decode('utf8')
680 self.assertEqual(expected, actual,681 self.assertEqual(expected, actual,
681 msg % ('yes_to_tc_checkbutton', expected, actual))682 msg % ('yes_to_tc_checkbutton', expected, actual))
682683
683 def test_checkbutton_is_checked_at_startup(self):684 def test_checkbutton_is_checked_at_startup(self):
684 """Checkbuttons are checked by default."""685 """Checkbuttons are checked by default."""
685 msg = '"%s" is checked by default.'686 msg = '%r is checked by default.'
686 name = 'yes_to_updates_checkbutton'687 name = 'yes_to_updates_checkbutton'
687 widget = getattr(self.ui, name)688 widget = getattr(self.ui, name)
688 self.assertTrue(widget.get_active(), msg % name)689 self.assertTrue(widget.get_active(), msg % name)
689690
690 def test_checkbutton_isnt_checked_at_startup(self):691 def test_checkbutton_isnt_checked_at_startup(self):
691 """Checkbuttons are checked by default."""692 """Checkbuttons are checked by default."""
692 msg = '"%s" is checked by default.'693 msg = '%r is checked by default.'
693 name = 'yes_to_tc_checkbutton'694 name = 'yes_to_tc_checkbutton'
694 widget = getattr(self.ui, name)695 widget = getattr(self.ui, name)
695 self.assertFalse(widget.get_active(), msg % name)696 self.assertFalse(widget.get_active(), msg % name)
@@ -732,7 +733,8 @@
732 'the processing spinner should be active.')733 'the processing spinner should be active.')
733 self.assertTrue(label.get_property('visible'),734 self.assertTrue(label.get_property('visible'),
734 'the processing label should be visible.')735 'the processing label should be visible.')
735 self.assertEqual(label.get_text(), gui.ONE_MOMENT_PLEASE,736 self.assertEqual(label.get_text().decode('utf8'),
737 gui.ONE_MOMENT_PLEASE,
736 'the processing label text must be correct.')738 'the processing label text must be correct.')
737739
738 def test_captcha_image_is_not_visible_at_startup(self):740 def test_captcha_image_is_not_visible_at_startup(self):
@@ -775,7 +777,7 @@
775 'the captcha_loading spinner should be active.')777 'the captcha_loading spinner should be active.')
776 self.assertTrue(label.get_property('visible'),778 self.assertTrue(label.get_property('visible'),
777 'the captcha_loading label should be visible.')779 'the captcha_loading label should be visible.')
778 self.assertEqual(label.get_text(), gui.LOADING,780 self.assertEqual(label.get_text().decode('utf8'), gui.LOADING,
779 'the captcha_loading label text must be correct.')781 'the captcha_loading label text must be correct.')
780782
781 def test_join_ok_button_is_disabled_until_captcha_is_available(self):783 def test_join_ok_button_is_disabled_until_captcha_is_available(self):
@@ -814,7 +816,7 @@
814 def test_on_captcha_generated_logs_captcha_id_when_none(self):816 def test_on_captcha_generated_logs_captcha_id_when_none(self):
815 """If the captcha id is None, a warning is logged."""817 """If the captcha id is None, a warning is logged."""
816 self.ui.on_captcha_generated(app_name=APP_NAME, captcha_id=None)818 self.ui.on_captcha_generated(app_name=APP_NAME, captcha_id=None)
817 self.assertTrue(self.memento.check(logging.WARNING, APP_NAME))819 self.assertTrue(self.memento.check(logging.WARNING, repr(APP_NAME)))
818 self.assertTrue(self.memento.check(logging.WARNING,820 self.assertTrue(self.memento.check(logging.WARNING,
819 'captcha_id is None'))821 'captcha_id is None'))
820822
@@ -837,7 +839,7 @@
837839
838 def test_login_button_has_correct_wording(self):840 def test_login_button_has_correct_wording(self):
839 """The sign in button has the proper wording."""841 """The sign in button has the proper wording."""
840 actual = self.ui.login_button.get_label()842 actual = self.ui.login_button.get_label().decode('utf8')
841 self.assertEqual(gui.LOGIN_BUTTON_LABEL, actual)843 self.assertEqual(gui.LOGIN_BUTTON_LABEL, actual)
842844
843 def test_join_ok_button_does_nothing_if_clicked_but_disabled(self):845 def test_join_ok_button_does_nothing_if_clicked_but_disabled(self):
@@ -870,7 +872,7 @@
870 """When captcha was retrieved after error, the warning is removed."""872 """When captcha was retrieved after error, the warning is removed."""
871 self.ui.on_captcha_generation_error(APP_NAME, error=self.error)873 self.ui.on_captcha_generation_error(APP_NAME, error=self.error)
872 self.ui.on_captcha_generated(app_name=APP_NAME, captcha_id=CAPTCHA_ID)874 self.ui.on_captcha_generated(app_name=APP_NAME, captcha_id=CAPTCHA_ID)
873 self.assertEqual(self.ui.warning_label.get_text(), '')875 self.assertEqual(self.ui.warning_label.get_text().decode('utf8'), '')
874876
875877
876class NoTermsAndConditionsTestCase(UbuntuSSOClientTestCase):878class NoTermsAndConditionsTestCase(UbuntuSSOClientTestCase):
@@ -953,12 +955,13 @@
953955
954 def test_tc_button_has_the_proper_wording(self):956 def test_tc_button_has_the_proper_wording(self):
955 """Terms & Conditions has the proper wording."""957 """Terms & Conditions has the proper wording."""
956 self.assertEqual(self.ui.tc_button.get_label(), gui.TC_BUTTON)958 self.assertEqual(self.ui.tc_button.get_label().decode('utf8'),
959 gui.TC_BUTTON)
957960
958 def test_tc_has_no_help_text(self):961 def test_tc_has_no_help_text(self):
959 """The help text is removed."""962 """The help text is removed."""
960 self.ui.on_tc_browser_notify_load_status(self.browser)963 self.ui.on_tc_browser_notify_load_status(self.browser)
961 self.assertEqual('', self.ui.help_label.get_text())964 self.assertEqual('', self.ui.help_label.get_text().decode('utf8'))
962965
963 def test_tc_browser_opens_the_proper_url(self):966 def test_tc_browser_opens_the_proper_url(self):
964 """Terms & Conditions browser shows the proper uri."""967 """Terms & Conditions browser shows the proper uri."""
@@ -1115,8 +1118,8 @@
11151118
1116 def test_help_label_display_correct_wording(self):1119 def test_help_label_display_correct_wording(self):
1117 """The help_label display VERIFY_EMAIL_LABEL."""1120 """The help_label display VERIFY_EMAIL_LABEL."""
1118 msg = 'help_label must read "%s" (got "%s" instead).'1121 msg = 'help_label must read %r (got %r instead).'
1119 actual = self.ui.help_label.get_label()1122 actual = self.ui.help_label.get_label().decode('utf8')
1120 expected = gui.VERIFY_EMAIL_LABEL % {'app_name': APP_NAME,1123 expected = gui.VERIFY_EMAIL_LABEL % {'app_name': APP_NAME,
1121 'email': EMAIL}1124 'email': EMAIL}
1122 self.assertEqual(expected, actual, msg % (expected, actual))1125 self.assertEqual(expected, actual, msg % (expected, actual))
@@ -1160,7 +1163,7 @@
1160 """On email validated the help text is not removed."""1163 """On email validated the help text is not removed."""
1161 self.ui.on_email_validated(app_name=APP_NAME, email=EMAIL)1164 self.ui.on_email_validated(app_name=APP_NAME, email=EMAIL)
1162 self.assertEqual(self.ui.verify_email_vbox.help_text,1165 self.assertEqual(self.ui.verify_email_vbox.help_text,
1163 self.ui.help_label.get_label())1166 self.ui.help_label.get_label().decode('utf8'))
11641167
1165 def test_on_email_validation_error_verify_email_is_shown(self):1168 def test_on_email_validation_error_verify_email_is_shown(self):
1166 """On email validation error, the verify_email page is shown."""1169 """On email validation error, the verify_email page is shown."""
@@ -1186,16 +1189,16 @@
1186 def test_success_label_is_correct(self):1189 def test_success_label_is_correct(self):
1187 """The success message is correct."""1190 """The success message is correct."""
1188 self.assertEqual(gui.SUCCESS % {'app_name': APP_NAME},1191 self.assertEqual(gui.SUCCESS % {'app_name': APP_NAME},
1189 self.ui.success_vbox.label.get_text())1192 self.ui.success_vbox.label.get_text().decode('utf8'))
1190 markup = self.ui.success_vbox.label.get_label()1193 markup = self.ui.success_vbox.label.get_label().decode('utf8')
1191 self.assertTrue('<span size="x-large">' in markup)1194 self.assertTrue('<span size="x-large">' in markup)
1192 self.assertTrue(self.ui.app_name in markup)1195 self.assertTrue(self.ui.app_name in markup)
11931196
1194 def test_error_label_is_correct(self):1197 def test_error_label_is_correct(self):
1195 """The error message is correct."""1198 """The error message is correct."""
1196 self.assertEqual(gui.ERROR,1199 self.assertEqual(gui.ERROR,
1197 self.ui.error_vbox.label.get_text())1200 self.ui.error_vbox.label.get_text().decode('utf8'))
1198 markup = self.ui.error_vbox.label.get_label()1201 markup = self.ui.error_vbox.label.get_label().decode('utf8')
1199 self.assertTrue('<span size="x-large">' in markup)1202 self.assertTrue('<span size="x-large">' in markup)
12001203
1201 def test_on_finish_close_button_clicked_closes_window(self):1204 def test_on_finish_close_button_clicked_closes_window(self):
@@ -1346,7 +1349,7 @@
1346 """Password help text is correctly displayed."""1349 """Password help text is correctly displayed."""
1347 self.assertTrue(self.ui.password_help_label.get_property('visible'),1350 self.assertTrue(self.ui.password_help_label.get_property('visible'),
1348 'password help text is visible.')1351 'password help text is visible.')
1349 self.assertEqual(self.ui.password_help_label.get_text(),1352 self.assertEqual(self.ui.password_help_label.get_text().decode('utf8'),
1350 gui.PASSWORD_HELP)1353 gui.PASSWORD_HELP)
1351 self.assertNotIn('register_user', self.ui.backend._called)1354 self.assertNotIn('register_user', self.ui.backend._called)
13521355
@@ -1436,16 +1439,16 @@
14361439
1437 def test_initial_text_for_header_label(self):1440 def test_initial_text_for_header_label(self):
1438 """The header must have the correct text when logging in."""1441 """The header must have the correct text when logging in."""
1439 msg = 'Text for the header must be "%s" (got "%s" instead).'1442 msg = 'Text for the header must be %r (got %r instead).'
1440 expected = gui.LOGIN_HEADER_LABEL % {'app_name': APP_NAME}1443 expected = gui.LOGIN_HEADER_LABEL % {'app_name': APP_NAME}
1441 actual = self.ui.header_label.get_text()1444 actual = self.ui.header_label.get_text().decode('utf8')
1442 self.assertEqual(expected, actual, msg % (expected, actual))1445 self.assertEqual(expected, actual, msg % (expected, actual))
14431446
1444 def test_initial_text_for_help_label(self):1447 def test_initial_text_for_help_label(self):
1445 """The help must have the correct text at startup."""1448 """The help must have the correct text at startup."""
1446 msg = 'Text for the help must be "%s" (got "%s" instead).'1449 msg = 'Text for the help must be %r (got %r instead).'
1447 expected = gui.CONNECT_HELP_LABEL % {'app_name': APP_NAME}1450 expected = gui.CONNECT_HELP_LABEL % {'app_name': APP_NAME}
1448 actual = self.ui.help_label.get_text()1451 actual = self.ui.help_label.get_text().decode('utf8')
1449 self.assertEqual(expected, actual, msg % (expected, actual))1452 self.assertEqual(expected, actual, msg % (expected, actual))
14501453
1451 def test_entries_are_packed_to_ui_for_login(self):1454 def test_entries_are_packed_to_ui_for_login(self):
@@ -1628,23 +1631,23 @@
16281631
1629 def test_forgotten_password_button_has_the_proper_wording(self):1632 def test_forgotten_password_button_has_the_proper_wording(self):
1630 """The forgotten_password_button has the proper wording."""1633 """The forgotten_password_button has the proper wording."""
1631 self.assertEqual(self.ui.forgotten_password_button.get_label(),1634 actual = self.ui.forgotten_password_button.get_label()
1632 gui.FORGOTTEN_PASSWORD_BUTTON)1635 self.assertEqual(actual.decode('utf8'), gui.FORGOTTEN_PASSWORD_BUTTON)
16331636
1634 def test_on_forgotten_password_button_clicked_help_text(self):1637 def test_on_forgotten_password_button_clicked_help_text(self):
1635 """Clicking forgotten_password_button the help is properly changed."""1638 """Clicking forgotten_password_button the help is properly changed."""
1636 wanted = gui.REQUEST_PASSWORD_TOKEN_LABEL % {'app_name': APP_NAME}1639 wanted = gui.REQUEST_PASSWORD_TOKEN_LABEL % {'app_name': APP_NAME}
1637 self.assertEqual(self.ui.help_label.get_text(), wanted)1640 self.assertEqual(self.ui.help_label.get_text().decode('utf8'), wanted)
16381641
1639 def test_on_forgotten_password_button_clicked_header_label(self):1642 def test_on_forgotten_password_button_clicked_header_label(self):
1640 """Clicking forgotten_password_button the title is properly changed."""1643 """Clicking forgotten_password_button the title is properly changed."""
1641 self.assertEqual(self.ui.header_label.get_text(),1644 self.assertEqual(self.ui.header_label.get_text().decode('utf8'),
1642 gui.RESET_PASSWORD)1645 gui.RESET_PASSWORD)
16431646
1644 def test_on_forgotten_password_button_clicked_ok_button(self):1647 def test_on_forgotten_password_button_clicked_ok_button(self):
1645 """Clicking forgotten_password_button the ok button reads 'Next'."""1648 """Clicking forgotten_password_button the ok button reads 'Next'."""
1646 self.assertEqual(self.ui.request_password_token_ok_button.get_label(),1649 actual = self.ui.request_password_token_ok_button.get_label()
1647 gui.NEXT)1650 self.assertEqual(actual.decode('utf8'), gui.NEXT)
16481651
1649 def test_on_forgotten_password_button_clicked_morphs_window(self):1652 def test_on_forgotten_password_button_clicked_morphs_window(self):
1650 """Clicking forgotten_password_button the proper page is shown."""1653 """Clicking forgotten_password_button the proper page is shown."""
@@ -1691,7 +1694,7 @@
1691 self.click_request_password_token_with_valid_data()1694 self.click_request_password_token_with_valid_data()
1692 self.ui.on_password_reset_token_sent(app_name=APP_NAME, email=EMAIL)1695 self.ui.on_password_reset_token_sent(app_name=APP_NAME, email=EMAIL)
16931696
1694 self.assertEqual(self.ui.help_label.get_text(),1697 self.assertEqual(self.ui.help_label.get_text().decode('utf8'),
1695 gui.SET_NEW_PASSWORD_LABEL % {'email': EMAIL})1698 gui.SET_NEW_PASSWORD_LABEL % {'email': EMAIL})
16961699
1697 def test_on_password_reset_token_sent_ok_button(self):1700 def test_on_password_reset_token_sent_ok_button(self):
@@ -1699,8 +1702,8 @@
1699 self.click_request_password_token_with_valid_data()1702 self.click_request_password_token_with_valid_data()
1700 self.ui.on_password_reset_token_sent(app_name=APP_NAME, email=EMAIL)1703 self.ui.on_password_reset_token_sent(app_name=APP_NAME, email=EMAIL)
17011704
1702 self.assertEqual(self.ui.set_new_password_ok_button.get_label(),1705 actual = self.ui.set_new_password_ok_button.get_label()
1703 gui.RESET_PASSWORD)1706 self.assertEqual(actual.decode('utf8'), gui.RESET_PASSWORD)
17041707
1705 def test_on_password_reset_error_shows_login_page(self):1708 def test_on_password_reset_error_shows_login_page(self):
1706 """When reset token wasn't successfuly sent the login page is shown."""1709 """When reset token wasn't successfuly sent the login page is shown."""
@@ -1872,8 +1875,8 @@
1872 """Password help text is correctly displayed."""1875 """Password help text is correctly displayed."""
1873 visible = self.ui.reset_password_help_label.get_property('visible')1876 visible = self.ui.reset_password_help_label.get_property('visible')
1874 self.assertTrue(visible, 'password help text is visible.')1877 self.assertTrue(visible, 'password help text is visible.')
1875 self.assertEqual(self.ui.reset_password_help_label.get_text(),1878 actual = self.ui.reset_password_help_label.get_text()
1876 gui.PASSWORD_HELP)1879 self.assertEqual(actual.decode('utf8'), gui.PASSWORD_HELP)
1877 self.assertNotIn('set_new_password', self.ui.backend._called)1880 self.assertNotIn('set_new_password', self.ui.backend._called)
18781881
1879 def test_warning_is_shown_if_password_mismatch(self):1882 def test_warning_is_shown_if_password_mismatch(self):
@@ -1951,7 +1954,7 @@
1951 """Callbacks do nothing but logging when app_name doesn't match."""1954 """Callbacks do nothing but logging when app_name doesn't match."""
1952 mismatch_app_name = self.ui.app_name * 21955 mismatch_app_name = self.ui.app_name * 2
1953 for method in self.ui._signals.itervalues():1956 for method in self.ui._signals.itervalues():
1954 msgs = ('ignoring', method.__name__, mismatch_app_name)1957 msgs = ('ignoring', method.__name__, repr(mismatch_app_name))
1955 method(mismatch_app_name, 'dummy')1958 method(mismatch_app_name, 'dummy')
1956 self.assertTrue(self.memento.check(logging.INFO, *msgs))1959 self.assertTrue(self.memento.check(logging.INFO, *msgs))
1957 self.memento.records = []1960 self.memento.records = []
@@ -2068,7 +2071,8 @@
20682071
2069 def test_help_text_is_used(self):2072 def test_help_text_is_used(self):
2070 """The passed help_text is used."""2073 """The passed help_text is used."""
2071 self.assertEqual(self.ui.help_label.get_text(), HELP_TEXT)2074 self.assertEqual(self.ui.help_label.get_text().decode('utf8'),
2075 HELP_TEXT)
20722076
20732077
2074class ReturnCodeTestCase(UbuntuSSOClientTestCase):2078class ReturnCodeTestCase(UbuntuSSOClientTestCase):
@@ -2087,7 +2091,7 @@
2087 def test_every_cancel_calls_proper_callback(self):2091 def test_every_cancel_calls_proper_callback(self):
2088 """When any cancel button is clicked, USER_CANCELLATION is called."""2092 """When any cancel button is clicked, USER_CANCELLATION is called."""
2089 self.patch(self.ui.backend, 'disconnect_from_signal', lambda *a: None)2093 self.patch(self.ui.backend, 'disconnect_from_signal', lambda *a: None)
2090 msg = 'USER_CANCELLATION should be returned when "%s" is clicked.'2094 msg = 'USER_CANCELLATION should be returned when %r is clicked.'
2091 buttons = filter(lambda name: 'cancel_button' in name, self.ui.widgets)2095 buttons = filter(lambda name: 'cancel_button' in name, self.ui.widgets)
2092 for name in buttons:2096 for name in buttons:
2093 widget = getattr(self.ui, name)2097 widget = getattr(self.ui, name)
20942098
=== modified file 'ubuntu_sso/keyring/tests/test_linux.py'
--- ubuntu_sso/keyring/tests/test_linux.py 2012-01-26 15:34:16 +0000
+++ ubuntu_sso/keyring/tests/test_linux.py 2012-02-18 14:14:18 +0000
@@ -26,7 +26,6 @@
2626
27from ubuntu_sso import keyring as common_keyring27from ubuntu_sso import keyring as common_keyring
28from ubuntu_sso.keyring import linux as keyring28from ubuntu_sso.keyring import linux as keyring
29from ubuntu_sso.tests import APP_NAME
3029
3130
32class MockItem(object):31class MockItem(object):
@@ -168,9 +167,9 @@
168 sample_creds = {"name": "sample creds name"}167 sample_creds = {"name": "sample creds name"}
169 kr = keyring.Keyring()168 kr = keyring.Keyring()
170 self.patch(keyring, "get_token_name", keyring.get_old_token_name)169 self.patch(keyring, "get_token_name", keyring.get_old_token_name)
171 yield kr.set_credentials(APP_NAME, sample_creds)170 yield kr.set_credentials("app name", sample_creds)
172171
173 result = yield kr.get_credentials(APP_NAME)172 result = yield kr.get_credentials("app name")
174 self.assertEqual(result, sample_creds)173 self.assertEqual(result, sample_creds)
175174
176 @inlineCallbacks175 @inlineCallbacks
177176
=== modified file 'ubuntu_sso/main/__init__.py'
--- ubuntu_sso/main/__init__.py 2012-02-11 01:51:57 +0000
+++ ubuntu_sso/main/__init__.py 2012-02-18 14:14:18 +0000
@@ -318,7 +318,7 @@
318 def CredentialsFound(self, app_name, credentials):318 def CredentialsFound(self, app_name, credentials):
319 """Signal thrown when the credentials are found."""319 """Signal thrown when the credentials are found."""
320 self.ref_count -= 1320 self.ref_count -= 1
321 logger.info('%s: emitting CredentialsFound with app_name "%s".',321 logger.info('%s: emitting CredentialsFound with app_name %r.',
322 self.__class__.__name__, app_name)322 self.__class__.__name__, app_name)
323 self.proxy.CredentialsFound(app_name, credentials)323 self.proxy.CredentialsFound(app_name, credentials)
324324
325325
=== modified file 'ubuntu_sso/main/tests/test_common.py'
--- ubuntu_sso/main/tests/test_common.py 2012-02-10 17:18:22 +0000
+++ ubuntu_sso/main/tests/test_common.py 2012-02-18 14:14:18 +0000
@@ -919,7 +919,8 @@
919 @defer.inlineCallbacks919 @defer.inlineCallbacks
920 def setUp(self):920 def setUp(self):
921 yield super(CredentialsManagementOpsTestCase, self).setUp()921 yield super(CredentialsManagementOpsTestCase, self).setUp()
922 self.args = dict((k, str(v)) for k, v in self.base_args.iteritems())922 self.args = dict(self.base_args)
923 self.args[WINDOW_ID_KEY] = str(self.args[WINDOW_ID_KEY])
923 self.cred_args = self.base_args.copy()924 self.cred_args = self.base_args.copy()
924925
925 def test_register(self):926 def test_register(self):
@@ -955,12 +956,16 @@
955class CredentialsManagementSignalsTestCase(CredentialsManagementTestCase):956class CredentialsManagementSignalsTestCase(CredentialsManagementTestCase):
956 """Tests for the CredentialsManagement DBus signals."""957 """Tests for the CredentialsManagement DBus signals."""
957958
959 def assert_signal_logged(self, signal, *args):
960 """Check that signal info was properly logged."""
961 signal(APP_NAME, *args)
962 msgs = [self.obj.__class__.__name__,
963 signal.__name__, repr(APP_NAME)]
964 self.assertTrue(self.memento.check_info(*msgs))
965
958 def test_credentials_found(self):966 def test_credentials_found(self):
959 """The CredentialsFound signal."""967 """The CredentialsFound signal."""
960 self.obj.CredentialsFound(APP_NAME, TOKEN)968 self.assert_signal_logged(self.obj.CredentialsFound, TOKEN)
961 msgs = (self.obj.__class__.__name__,
962 self.obj.CredentialsFound.__name__, APP_NAME)
963 self.assertTrue(self.memento.check_info(*msgs))
964969
965 msg = 'credentials must not be logged (found %r in log).'970 msg = 'credentials must not be logged (found %r in log).'
966 for val in TOKEN.itervalues():971 for val in TOKEN.itervalues():
@@ -968,24 +973,15 @@
968973
969 def test_credentials_not_found(self):974 def test_credentials_not_found(self):
970 """The CredentialsNotFound signal."""975 """The CredentialsNotFound signal."""
971 self.obj.CredentialsNotFound(APP_NAME)976 self.assert_signal_logged(self.obj.CredentialsNotFound)
972 msgs = (self.obj.__class__.__name__,
973 self.obj.CredentialsNotFound.__name__, APP_NAME)
974 self.assertTrue(self.memento.check_info(*msgs))
975977
976 def test_credentials_cleared(self):978 def test_credentials_cleared(self):
977 """The CredentialsCleared signal."""979 """The CredentialsCleared signal."""
978 self.obj.CredentialsCleared(APP_NAME)980 self.assert_signal_logged(self.obj.CredentialsCleared)
979 msgs = (self.obj.__class__.__name__,
980 self.obj.CredentialsCleared.__name__, APP_NAME)
981 self.assertTrue(self.memento.check_info(*msgs))
982981
983 def test_credentials_stored(self):982 def test_credentials_stored(self):
984 """The CredentialsStored signal."""983 """The CredentialsStored signal."""
985 self.obj.CredentialsStored(APP_NAME)984 self.assert_signal_logged(self.obj.CredentialsStored)
986 msgs = (self.obj.__class__.__name__,
987 self.obj.CredentialsStored.__name__, APP_NAME)
988 self.assertTrue(self.memento.check_info(*msgs))
989985
990 def test_credentials_error(self):986 def test_credentials_error(self):
991 """The CredentialsError signal."""987 """The CredentialsError signal."""
@@ -993,15 +989,12 @@
993 self.obj.CredentialsError(APP_NAME, error)989 self.obj.CredentialsError(APP_NAME, error)
994 msgs = (self.obj.__class__.__name__,990 msgs = (self.obj.__class__.__name__,
995 self.obj.CredentialsError.__name__,991 self.obj.CredentialsError.__name__,
996 APP_NAME, str(error))992 repr(APP_NAME), repr(error))
997 self.assertTrue(self.memento.check_error(*msgs))993 self.assertTrue(self.memento.check_error(*msgs))
998994
999 def test_authorization_denied(self):995 def test_authorization_denied(self):
1000 """The AuthorizationDenied signal."""996 """The AuthorizationDenied signal."""
1001 self.obj.AuthorizationDenied(APP_NAME)997 self.assert_signal_logged(self.obj.AuthorizationDenied)
1002 msgs = (self.obj.__class__.__name__,
1003 self.obj.AuthorizationDenied.__name__, APP_NAME)
1004 self.assertTrue(self.memento.check_info(*msgs))
1005998
1006999
1007class UbuntuSSOServiceTestCase(BaseTestCase):1000class UbuntuSSOServiceTestCase(BaseTestCase):
10081001
=== modified file 'ubuntu_sso/qt/__init__.py'
--- ubuntu_sso/qt/__init__.py 2012-02-09 18:28:40 +0000
+++ ubuntu_sso/qt/__init__.py 2012-02-18 14:14:18 +0000
@@ -16,21 +16,11 @@
1616
17"""The Qt graphical interface for the Ubuntu Single Sign On Client."""17"""The Qt graphical interface for the Ubuntu Single Sign On Client."""
1818
19import gettext
20import collections19import collections
2120
2221
23_ = gettext.gettext
24
25ERROR_ALL = '__all__'22ERROR_ALL = '__all__'
26ERROR_MESSAGE = 'message'23ERROR_MESSAGE = 'message'
27LOCAL_FOLDERS_TITLE = _("Syncing your computer with the cloud")
28LOCAL_FOLDERS_SPACE_HEADER = _("Space (%s)")
29LOCAL_FOLDERS_OFFER_LABEL = _("The folders you have selected to sync "
30 "take over your %(quota)s space. You can remove some folders or add "
31 "some extra space")
32LOCAL_FOLDERS_CALCULATING = _("Calculating")
33NEXT = _("Next")
3424
3525
36# Based on the gtk implementation26# Based on the gtk implementation
3727
=== modified file 'ubuntu_sso/qt/current_user_sign_in_page.py'
--- ubuntu_sso/qt/current_user_sign_in_page.py 2012-02-14 14:38:23 +0000
+++ ubuntu_sso/qt/current_user_sign_in_page.py 2012-02-18 14:14:18 +0000
@@ -16,7 +16,6 @@
1616
17"""Page to allow the user to login into Ubuntu Single Sign On."""17"""Page to allow the user to login into Ubuntu Single Sign On."""
1818
19import gettext
20from functools import partial19from functools import partial
2120
22from PyQt4 import QtGui, QtCore21from PyQt4 import QtGui, QtCore
@@ -27,6 +26,7 @@
27from ubuntu_sso.qt.gui import SSOWizardPage26from ubuntu_sso.qt.gui import SSOWizardPage
28from ubuntu_sso.logger import setup_logging27from ubuntu_sso.logger import setup_logging
29from ubuntu_sso.utils.ui import (28from ubuntu_sso.utils.ui import (
29 CANCEL_BUTTON,
30 EMAIL_LABEL,30 EMAIL_LABEL,
31 FORGOTTEN_PASSWORD_BUTTON,31 FORGOTTEN_PASSWORD_BUTTON,
32 is_correct_email,32 is_correct_email,
@@ -38,7 +38,6 @@
38FORGOTTEN_PASSWORD_LINK_STYLE = '<a href="#">{forgotten_text}</a>'38FORGOTTEN_PASSWORD_LINK_STYLE = '<a href="#">{forgotten_text}</a>'
3939
4040
41_ = gettext.gettext
42logger = setup_logging('ubuntu_sso.current_user_sign_in_page')41logger = setup_logging('ubuntu_sso.current_user_sign_in_page')
4342
4443
@@ -87,8 +86,7 @@
8786
88 def initializePage(self):87 def initializePage(self):
89 """Setup UI details."""88 """Setup UI details."""
90 self.setButtonText(QtGui.QWizard.CancelButton,89 self.setButtonText(QtGui.QWizard.CancelButton, CANCEL_BUTTON)
91 _("Cancel"))
92 # Layout without custom button 1,90 # Layout without custom button 1,
93 # without finish button91 # without finish button
94 self.wizard().setButtonLayout([92 self.wizard().setButtonLayout([
9593
=== modified file 'ubuntu_sso/qt/gui.py'
--- ubuntu_sso/qt/gui.py 2012-02-14 14:38:23 +0000
+++ ubuntu_sso/qt/gui.py 2012-02-18 14:14:18 +0000
@@ -15,7 +15,6 @@
15# with this program. If not, see <http://www.gnu.org/licenses/>.15# with this program. If not, see <http://www.gnu.org/licenses/>.
16"""Qt implementation of the UI."""16"""Qt implementation of the UI."""
1717
18import gettext
19from functools import wraps18from functools import wraps
2019
21# pylint: disable=F0401,E061120# pylint: disable=F0401,E0611
@@ -40,7 +39,6 @@
40from ubuntu_sso.utils.ui import GENERIC_BACKEND_ERROR39from ubuntu_sso.utils.ui import GENERIC_BACKEND_ERROR
4140
4241
43_ = gettext.gettext
44logger = setup_logging('ubuntu_sso.gui')42logger = setup_logging('ubuntu_sso.gui')
4543
4644
4745
=== modified file 'ubuntu_sso/qt/network_detection_page.py'
--- ubuntu_sso/qt/network_detection_page.py 2012-02-13 20:27:48 +0000
+++ ubuntu_sso/qt/network_detection_page.py 2012-02-18 14:14:18 +0000
@@ -16,17 +16,17 @@
1616
17"""Pages from SSO."""17"""Pages from SSO."""
1818
19
20import gettext
21
22from twisted.internet import defer19from twisted.internet import defer
23from PyQt4 import QtGui20from PyQt4 import QtGui
2421
25from ubuntu_sso import networkstate22from ubuntu_sso import networkstate
2623
27from ubuntu_sso.qt.ui import network_detection_ui24from ubuntu_sso.qt.ui import network_detection_ui
2825from ubuntu_sso.utils.ui import (
29_ = gettext.gettext26 CLOSE_AND_SETUP_LATER,
27 NETWORK_DETECTION_TITLE,
28 TRY_AGAIN_BUTTON,
29)
3030
3131
32class NetworkDetectionPage(QtGui.QWizardPage):32class NetworkDetectionPage(QtGui.QWizardPage):
@@ -35,7 +35,7 @@
3535
36 def __init__(self, banner_pixmap=None, parent=None):36 def __init__(self, banner_pixmap=None, parent=None):
37 super(NetworkDetectionPage, self).__init__(parent)37 super(NetworkDetectionPage, self).__init__(parent)
38 self.setTitle(_("Network detection"))38 self.setTitle(NETWORK_DETECTION_TITLE)
39 self.ui = network_detection_ui.Ui_Form()39 self.ui = network_detection_ui.Ui_Form()
40 self.ui.setupUi(self)40 self.ui.setupUi(self)
41 if banner_pixmap is not None:41 if banner_pixmap is not None:
@@ -47,9 +47,9 @@
47 """Set UI details."""47 """Set UI details."""
48 self.wizard()._next_id = None48 self.wizard()._next_id = None
4949
50 self.setButtonText(QtGui.QWizard.CustomButton1, _("Try again"))50 self.setButtonText(QtGui.QWizard.CustomButton1, TRY_AGAIN_BUTTON)
51 self.setButtonText(QtGui.QWizard.CancelButton,51 self.setButtonText(QtGui.QWizard.CancelButton,
52 _("Close window and set up later"))52 CLOSE_AND_SETUP_LATER)
53 self.wizard().setButtonLayout([53 self.wizard().setButtonLayout([
54 QtGui.QWizard.Stretch,54 QtGui.QWizard.Stretch,
55 QtGui.QWizard.CustomButton1,55 QtGui.QWizard.CustomButton1,
5656
=== modified file 'ubuntu_sso/qt/setup_account_page.py'
--- ubuntu_sso/qt/setup_account_page.py 2012-02-15 17:33:40 +0000
+++ ubuntu_sso/qt/setup_account_page.py 2012-02-18 14:14:18 +0000
@@ -55,7 +55,6 @@
55 is_min_required_password,55 is_min_required_password,
56 is_correct_email,56 is_correct_email,
57 JOIN_HEADER_LABEL,57 JOIN_HEADER_LABEL,
58 NAME,
59 NAME_ENTRY,58 NAME_ENTRY,
60 NAME_INVALID,59 NAME_INVALID,
61 PASSWORD,60 PASSWORD,
@@ -177,7 +176,7 @@
177 self.set_up_button.clicked.connect(self.set_next_validation)176 self.set_up_button.clicked.connect(self.set_next_validation)
178 self.set_up_button.setEnabled(False)177 self.set_up_button.setEnabled(False)
179178
180 self.ui.name_label.setText(NAME)179 self.ui.name_label.setText(NAME_ENTRY)
181 self.ui.email_label.setText(EMAIL)180 self.ui.email_label.setText(EMAIL)
182 self.ui.confirm_email_label.setText(RETYPE_EMAIL)181 self.ui.confirm_email_label.setText(RETYPE_EMAIL)
183 self.ui.password_label.setText(PASSWORD)182 self.ui.password_label.setText(PASSWORD)
@@ -200,7 +199,7 @@
200 #pylint: enable=C0103199 #pylint: enable=C0103
201200
202 def _set_translated_strings(self):201 def _set_translated_strings(self):
203 """Set the different gettext translated strings."""202 """Set the strings."""
204 logger.debug('SetUpAccountPage._set_translated_strings')203 logger.debug('SetUpAccountPage._set_translated_strings')
205 # set the translated string204 # set the translated string
206 self.ui.name_label.setText(NAME_ENTRY)205 self.ui.name_label.setText(NAME_ENTRY)
207206
=== modified file 'ubuntu_sso/qt/sign_in_page.py'
--- ubuntu_sso/qt/sign_in_page.py 2012-02-13 20:27:48 +0000
+++ ubuntu_sso/qt/sign_in_page.py 2012-02-18 14:14:18 +0000
@@ -16,19 +16,17 @@
1616
17"""Page to allow the user to sign in."""17"""Page to allow the user to sign in."""
1818
19import gettext
20
21from PyQt4 import QtGui, QtCore19from PyQt4 import QtGui, QtCore
2220
23from ubuntu_sso.qt.gui import SSOWizardPage21from ubuntu_sso.qt.gui import SSOWizardPage
24from ubuntu_sso.logger import setup_logging22from ubuntu_sso.logger import setup_logging
25from ubuntu_sso.utils.ui import (23from ubuntu_sso.utils.ui import (
24 CLOSE_AND_SETUP_LATER,
26 EXISTING_ACCOUNT_CHOICE_BUTTON,25 EXISTING_ACCOUNT_CHOICE_BUTTON,
27 SET_UP_ACCOUNT_CHOICE_BUTTON,26 SET_UP_ACCOUNT_CHOICE_BUTTON,
28)27)
2928
3029
31_ = gettext.gettext
32logger = setup_logging('ubuntu_sso.sing_in_page')30logger = setup_logging('ubuntu_sso.sing_in_page')
3331
3432
@@ -76,7 +74,7 @@
7674
77 def initializePage(self):75 def initializePage(self):
78 """Setup UI details."""76 """Setup UI details."""
79 self.ui.cancel_button.setText(_("Close window and setup later"))77 self.ui.cancel_button.setText(CLOSE_AND_SETUP_LATER)
80 self.ui.cancel_button.clicked.connect(self.singInCanceled.emit)78 self.ui.cancel_button.clicked.connect(self.singInCanceled.emit)
81 # Layout without custom button 1,79 # Layout without custom button 1,
82 # without finish button80 # without finish button
8381
=== modified file 'ubuntu_sso/qt/tests/test_setup_account.py'
--- ubuntu_sso/qt/tests/test_setup_account.py 2012-02-16 14:37:19 +0000
+++ ubuntu_sso/qt/tests/test_setup_account.py 2012-02-18 14:14:18 +0000
@@ -232,7 +232,8 @@
232 self.assertFalse(self.ui.captcha_received)232 self.assertFalse(self.ui.captcha_received)
233233
234 # labels234 # labels
235 self.assertEqual(self.ui.ui.name_label.text(), setup_account_page.NAME)235 self.assertEqual(self.ui.ui.name_label.text(),
236 setup_account_page.NAME_ENTRY)
236 self.assertEqual(self.ui.ui.email_label.text(),237 self.assertEqual(self.ui.ui.email_label.text(),
237 setup_account_page.EMAIL)238 setup_account_page.EMAIL)
238 self.assertEqual(self.ui.ui.confirm_email_label.text(),239 self.assertEqual(self.ui.ui.confirm_email_label.text(),
239240
=== modified file 'ubuntu_sso/tests/__init__.py'
--- ubuntu_sso/tests/__init__.py 2012-02-10 17:18:22 +0000
+++ ubuntu_sso/tests/__init__.py 2012-02-18 14:14:18 +0000
@@ -26,20 +26,20 @@
2626
27from ubuntu_sso.keyring import get_token_name27from ubuntu_sso.keyring import get_token_name
2828
29APP_NAME = u'The Super App!'29APP_NAME = u'I ♥ Ubuntu'
30CAPTCHA_ID = u'test ñiña'30CAPTCHA_ID = u'test ñiña'
31CAPTCHA_PATH = os.path.abspath(os.path.join(os.curdir, 'ubuntu_sso', 'tests',31CAPTCHA_PATH = os.path.abspath(os.path.join(os.curdir, 'ubuntu_sso', 'tests',
32 'files', 'captcha.png'))32 'files', 'captcha.png'))
33CAPTCHA_SOLUTION = u'william Byrd ñandú'33CAPTCHA_SOLUTION = u'william Byrd ñandú'
34EMAIL = u'test@example.com'34EMAIL = u'test@example.com'
35EMAIL_TOKEN = u'B2Pgtf'35EMAIL_TOKEN = u'B2P☺ gtf'
36GTK_GUI_EXE = 'ubuntu-sso-login-gtk'36GTK_GUI_EXE = 'ubuntu-sso-login-gtk'
37HELP_TEXT = """Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sed37HELP_TEXT = u'☛ Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' \
38lorem nibh. Suspendisse gravida nulla non nunc suscipit pulvinar tempus ut38'Nam sed lorem nibh. Suspendisse gravida nulla non nunc suscipit pulvinar ' \
39augue. Morbi consequat, ligula a elementum pretium, dolor nulla tempus metus,39'tempus ut augue. Morbi consequat, ligula a elementum pretium, ' \
40sed viverra nisi risus non velit."""40'dolor nulla tempus metus, sed viverra nisi risus non velit.'
41NAME = u'Juanito Pérez'41NAME = u'Juanito ☀ Pérez'
42PASSWORD = u'h3lloWorld'42PASSWORD = u'h3lloWorld☑ '
43PING_URL = u'http://localhost/ping-me/'43PING_URL = u'http://localhost/ping-me/'
44POLICY_URL = u'http://localhost/policy/'44POLICY_URL = u'http://localhost/policy/'
45RESET_PASSWORD_TOKEN = u'8G5Wtq'45RESET_PASSWORD_TOKEN = u'8G5Wtq'
4646
=== modified file 'ubuntu_sso/utils/runner/glib.py'
--- ubuntu_sso/utils/runner/glib.py 2012-02-10 17:03:56 +0000
+++ ubuntu_sso/utils/runner/glib.py 2012-02-18 14:14:18 +0000
@@ -27,7 +27,7 @@
27logger = setup_logging("ubuntu_sso.utils.runner.glib")27logger = setup_logging("ubuntu_sso.utils.runner.glib")
2828
2929
30NO_SUCH_FILE_OR_DIR = '(No such file or directory)'30NO_SUCH_FILE_OR_DIR = 'No such file or directory'
3131
3232
33def spawn_program(args, reply_handler, error_handler):33def spawn_program(args, reply_handler, error_handler):
@@ -66,8 +66,17 @@
66 GLib.SpawnFlags.STDOUT_TO_DEV_NULL | \66 GLib.SpawnFlags.STDOUT_TO_DEV_NULL | \
67 GLib.SpawnFlags.STDERR_TO_DEV_NULL67 GLib.SpawnFlags.STDERR_TO_DEV_NULL
68 pid = None68 pid = None
69
70 bytes_args = []
71 for arg in args:
72 if isinstance(arg, unicode):
73 arg = arg.encode('utf-8')
74 if not isinstance(arg, basestring):
75 arg = str(arg)
76 bytes_args.append(arg)
77
69 try:78 try:
70 pid, _, _, _ = GLib.spawn_async(argv=args, flags=flags)79 pid, _, _, _ = GLib.spawn_async(argv=bytes_args, flags=flags)
71 except GLib.GError, e:80 except GLib.GError, e:
72 handle_error(e)81 handle_error(e)
73 else:82 else:
7483
=== added file 'ubuntu_sso/utils/runner/tests/test_glib.py'
--- ubuntu_sso/utils/runner/tests/test_glib.py 1970-01-01 00:00:00 +0000
+++ ubuntu_sso/utils/runner/tests/test_glib.py 2012-02-18 14:14:18 +0000
@@ -0,0 +1,132 @@
1# -*- coding: utf-8 -*-
2#
3# Copyright 2012 Canonical Ltd.
4#
5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program. If not, see <http://www.gnu.org/licenses/>.
16
17"""Tests for the glib runner helper module."""
18
19import subprocess
20
21# pylint: disable=E0611
22from gi.repository import GLib
23# pylint: enable=E0611
24from twisted.internet import defer
25
26from ubuntu_sso.utils import runner
27from ubuntu_sso.utils.runner import glib
28from ubuntu_sso.utils.runner.tests.test_runner import SpawnProgramTestCase
29
30
31class FakedSignal(object):
32 """Fake a glib signal."""
33
34 def __init__(self, name):
35 self.name = name
36 self._handlers = []
37
38 def connect(self, handler):
39 """Connect 'handler' with this signal."""
40 self._handlers.append(handler)
41
42 def emit(self, *args, **kwargs):
43 """Emit this signal."""
44 for handler in self._handlers:
45 handler(*args, **kwargs)
46
47
48class FakedProcess(object):
49 """Fake a glib Process."""
50
51 _argv = _flags = None
52 _pid = 123456
53 _pids = []
54 _status_code = 0
55
56 SpawnFlags = GLib.SpawnFlags
57 GError = GLib.GError
58
59 def __init__(self):
60 self.pid = lambda: self._pid
61 self.started = FakedSignal('started')
62 self.finished = FakedSignal('finished')
63 self.error = FakedSignal('error')
64
65 def spawn_async(self, argv, flags):
66 """Spwan a process."""
67 if 'None' in argv:
68 exc = GLib.GError()
69 exc.message = str('Can not handle None')
70 exc.code = 24
71 raise exc
72
73 self._argv = argv
74 self._flags = flags
75
76 try:
77 subprocess.call(argv)
78 except Exception, e:
79 exc = GLib.GError()
80 exc.message = str(e)
81 exc.code = 42
82 raise exc
83
84 self._pids.append(self._pid)
85 return (self._pid, None, None, None)
86
87 def child_watch_add(self, pid, child_watch):
88 """Addd a child watch."""
89 if pid in self._pids:
90 child_watch(pid, self._status_code)
91
92 def spawn_close_pid(self, pid):
93 """Close the 'pid'."""
94 self._pids.remove(pid)
95
96
97class GLibSpawnProgramTestCase(SpawnProgramTestCase):
98 """The test suite for the spawn_program method (using GLib)."""
99
100 use_reactor = False
101
102 @defer.inlineCallbacks
103 def setUp(self):
104 yield super(GLibSpawnProgramTestCase, self).setUp()
105 # Since we can't mix plan glib runner and the gireactor, we patch
106 # GLib.spawn_async and fake the conditions so the glib runner is chosen
107 self.process = FakedProcess()
108 self.patch(glib, 'GLib', self.process)
109 self.patch(runner, 'is_twisted_reactor_installed', lambda: False)
110 self.patch(runner, 'is_qt4_main_loop_installed', lambda: False)
111
112 # Access to a protected member _flags, _argv of a client class
113 # pylint: disable=W0212
114
115 @defer.inlineCallbacks
116 def test_flags_are_correct(self):
117 """The flags are the correct ones."""
118 yield self.spawn_fn(self.args)
119
120 flags = GLib.SpawnFlags.DO_NOT_REAP_CHILD | \
121 GLib.SpawnFlags.SEARCH_PATH | \
122 GLib.SpawnFlags.STDOUT_TO_DEV_NULL | \
123 GLib.SpawnFlags.STDERR_TO_DEV_NULL
124 self.assertEqual(self.process._flags, flags)
125
126 @defer.inlineCallbacks
127 def test_argv_is_bytes(self):
128 """The argv parameter is converted to bytes."""
129 yield self.spawn_fn(self.args)
130
131 bytes_args = [a.encode('utf-8') for a in self.args]
132 self.assertEqual(self.process._argv, bytes_args)
0133
=== modified file 'ubuntu_sso/utils/runner/tests/test_qt.py'
--- ubuntu_sso/utils/runner/tests/test_qt.py 2012-02-10 15:44:28 +0000
+++ ubuntu_sso/utils/runner/tests/test_qt.py 2012-02-18 14:14:18 +0000
@@ -64,8 +64,16 @@
64 self.started.emit()64 self.started.emit()
6565
66 args = (program,) + tuple(arguments)66 args = (program,) + tuple(arguments)
67
68 # subprocess expects bytes
69 bytes_args = []
70 for arg in args:
71 if isinstance(arg, unicode):
72 arg = arg.encode('utf-8')
73 bytes_args.append(arg)
74
67 try:75 try:
68 subprocess.call(args)76 subprocess.call(bytes_args)
69 except OSError, e:77 except OSError, e:
70 if e.errno == 2:78 if e.errno == 2:
71 self.error.emit(self.FailedToStart)79 self.error.emit(self.FailedToStart)
7280
=== modified file 'ubuntu_sso/utils/runner/tests/test_runner.py'
--- ubuntu_sso/utils/runner/tests/test_runner.py 2012-02-08 02:13:03 +0000
+++ ubuntu_sso/utils/runner/tests/test_runner.py 2012-02-18 14:14:18 +0000
@@ -24,21 +24,23 @@
24from ubuntu_sso.utils import runner24from ubuntu_sso.utils import runner
2525
2626
27TEST_ME_DIR = 'test-me'27TEST_ME_DIR = u'test-me-more-♥'
28TEST_ME_DIR_BYTES = TEST_ME_DIR.encode('utf-8')
2829
2930
30class SpawnProgramTestCase(TestCase):31class SpawnProgramTestCase(TestCase):
31 """The test suite for the spawn_program method."""32 """The test suite for the spawn_program method."""
3233
33 timeout = 334 timeout = 3
34 args = ('python', '-c', 'import os; os.system("mkdir %s")' % TEST_ME_DIR)35 args = (u'python', u'-c',
36 u'import os; os.system("mkdir %s")' % TEST_ME_DIR)
3537
36 @defer.inlineCallbacks38 @defer.inlineCallbacks
37 def setUp(self):39 def setUp(self):
38 yield super(SpawnProgramTestCase, self).setUp()40 yield super(SpawnProgramTestCase, self).setUp()
39 assert not os.path.exists(TEST_ME_DIR)41 assert not os.path.exists(TEST_ME_DIR_BYTES)
40 self.addCleanup(lambda: os.path.exists(TEST_ME_DIR) and42 self.addCleanup(lambda: os.path.exists(TEST_ME_DIR_BYTES) and
41 os.rmdir(TEST_ME_DIR))43 os.rmdir(TEST_ME_DIR_BYTES))
4244
43 def spawn_fn(self, args):45 def spawn_fn(self, args):
44 """The target function to test."""46 """The target function to test."""
@@ -46,8 +48,8 @@
4648
47 def assert_command_was_run(self):49 def assert_command_was_run(self):
48 """The spawnned commnad was correctly run."""50 """The spawnned commnad was correctly run."""
49 self.assertTrue(os.path.exists(TEST_ME_DIR))51 self.assertTrue(os.path.exists(TEST_ME_DIR_BYTES))
50 self.assertTrue(os.path.isdir(TEST_ME_DIR))52 self.assertTrue(os.path.isdir(TEST_ME_DIR_BYTES))
5153
52 @defer.inlineCallbacks54 @defer.inlineCallbacks
53 def test_program_is_spawned(self):55 def test_program_is_spawned(self):
5456
=== modified file 'ubuntu_sso/utils/runner/tx.py'
--- ubuntu_sso/utils/runner/tx.py 2012-02-08 18:29:39 +0000
+++ ubuntu_sso/utils/runner/tx.py 2012-02-18 14:14:18 +0000
@@ -68,6 +68,14 @@
68 program = args[0]68 program = args[0]
69 argv = args[1:]69 argv = args[1:]
7070
71 bytes_args = []
72 for arg in argv:
73 if isinstance(arg, unicode):
74 arg = arg.encode('utf-8')
75 if not isinstance(arg, basestring):
76 arg = str(arg)
77 bytes_args.append(arg)
78
71 if program and not os.access(program, os.X_OK):79 if program and not os.access(program, os.X_OK):
72 # handle searching the executable in the PATH, since80 # handle searching the executable in the PATH, since
73 # twisted will not solve that for us :-/81 # twisted will not solve that for us :-/
@@ -81,7 +89,7 @@
81 break89 break
8290
83 try:91 try:
84 d = utils.getProcessOutputAndValue(program, argv, env=os.environ)92 d = utils.getProcessOutputAndValue(program, bytes_args, env=os.environ)
85 except OSError, e:93 except OSError, e:
86 error_handler(msg=e, failed_to_start=True)94 error_handler(msg=e, failed_to_start=True)
87 except Exception, e:95 except Exception, e:
8896
=== modified file 'ubuntu_sso/utils/ui.py'
--- ubuntu_sso/utils/ui.py 2012-02-13 20:27:48 +0000
+++ ubuntu_sso/utils/ui.py 2012-02-18 14:14:18 +0000
@@ -21,11 +21,12 @@
2121
22from ubuntu_sso.logger import setup_logging22from ubuntu_sso.logger import setup_logging
2323
24
25gettext.install('ubuntu-sso-client', unicode=True)
24logger = setup_logging('ubuntu_sso.utils.ui')26logger = setup_logging('ubuntu_sso.utils.ui')
2527
2628
27gettext.textdomain('ubuntu-sso-client')29# Undefined variable '_', pylint: disable=E0602
28_ = gettext.gettext
2930
30# all the text that is used in the gui31# all the text that is used in the gui
31AGREE_TO_PRIVACY_POLICY = _('By signing up to {app_name} you agree to '32AGREE_TO_PRIVACY_POLICY = _('By signing up to {app_name} you agree to '
@@ -33,11 +34,13 @@
33AGREE_TO_TERMS = _('By signing up to {app_name} you agree to '34AGREE_TO_TERMS = _('By signing up to {app_name} you agree to '
34 'our {terms_and_conditions}')35 'our {terms_and_conditions}')
35AGREE_TO_TERMS_AND_PRIVACY_POLICY = AGREE_TO_TERMS + _(' and {privacy_policy}')36AGREE_TO_TERMS_AND_PRIVACY_POLICY = AGREE_TO_TERMS + _(' and {privacy_policy}')
37CANCEL_BUTTON = _('Cancel')
36CAPTCHA_SOLUTION_ENTRY = _('Type the characters above')38CAPTCHA_SOLUTION_ENTRY = _('Type the characters above')
37CAPTCHA_LOAD_ERROR = _('There was a problem getting the captcha, '39CAPTCHA_LOAD_ERROR = _('There was a problem getting the captcha, '
38 'reloading...')40 'reloading...')
39CAPTCHA_RELOAD_TOOLTIP = _('Reload')41CAPTCHA_RELOAD_TOOLTIP = _('Reload')
40CAPTCHA_REQUIRED_ERROR = _('The captcha is a required field')42CAPTCHA_REQUIRED_ERROR = _('The captcha is a required field')
43CLOSE_AND_SETUP_LATER = _('Close window and setup later')
41CONGRATULATIONS = _("Congratulations, {app_name} is installed!")44CONGRATULATIONS = _("Congratulations, {app_name} is installed!")
42PROXY_CREDS_DIALOG_TITLE = _('Add proxy settings')45PROXY_CREDS_DIALOG_TITLE = _('Add proxy settings')
43PROXY_CREDS_HEADER = _('You are connecting through a proxy.')46PROXY_CREDS_HEADER = _('You are connecting through a proxy.')
@@ -76,10 +79,10 @@
76LOGIN_HEADER_LABEL = _('Connect to %(app_name)s')79LOGIN_HEADER_LABEL = _('Connect to %(app_name)s')
77LOGIN_PASSWORD_ENTRY = _('Password')80LOGIN_PASSWORD_ENTRY = _('Password')
78LOGIN_PASSWORD_LABEL = LOGIN_PASSWORD_ENTRY81LOGIN_PASSWORD_LABEL = LOGIN_PASSWORD_ENTRY
79NAME = _("Name")
80NAME_ENTRY = _('Name')82NAME_ENTRY = _('Name')
81NAME_INVALID = _('The name must not be empty.')83NAME_INVALID = _('The name must not be empty.')
82NEXT = _('Next')84NEXT = _('Next')
85NETWORK_DETECTION_TITLE = _('Network detection')
83ONE_MOMENT_PLEASE = _('One moment please...')86ONE_MOMENT_PLEASE = _('One moment please...')
84PASSWORD = _("Create a password")87PASSWORD = _("Create a password")
85PASSWORD_CHANGED = _('Your password was successfully changed.')88PASSWORD_CHANGED = _('Your password was successfully changed.')
@@ -140,6 +143,8 @@
140YES_TO_TC = _('I agree with the %(app_name)s terms and conditions')143YES_TO_TC = _('I agree with the %(app_name)s terms and conditions')
141YES_TO_UPDATES = _('Yes! Email me %(app_name)s tips and updates.')144YES_TO_UPDATES = _('Yes! Email me %(app_name)s tips and updates.')
142145
146# pylint: enable=E0602
147
143148
144def get_password_strength(password):149def get_password_strength(password):
145 """Return the strength of the password.150 """Return the strength of the password.

Subscribers

People subscribed via source and target branches