Merge lp:~nataliabidart/ubuntu-sso-client/fix-933632 into lp:ubuntu-sso-client
- fix-933632
- Merge into trunk
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 | ||||
Related bugs: |
|
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).
Description of the change
Roberto Alsina (ralsina) wrote : | # |
Looks good to me!
Ubuntu One Auto Pilot (otto-pilot) wrote : | # |
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.
TestCase
runTest ... [OK]
ubuntu_
TestGetHostname
test_
test_
TestTokenName
test_
test_
test_
test_
test_
twisted.
TestCase
runTest ... [OK]
ubuntu_
TestKeyring
test_
test_
test_
test_
test_
test_
test_
ubuntu_
NetworkManage
test_
test_
NetworkManage
test_
test_
test_
test_
test_nm_offline ... [OK]
test_
test_
test_
test_
test_
ubuntu_sso.tests
TestCase
runTest ... [OK]
ubuntu_
TestConnection
test_
test_
test_
test_
Ubuntu One Auto Pilot (otto-pilot) wrote : | # |
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.
TestCase
runTest ... [OK]
ubuntu_
TestGetHostname
test_
test_
TestTokenName
test_
test_
test_
test_
test_
twisted.
TestCase
runTest ... [OK]
ubuntu_
TestKeyring
test_
test_
test_
test_
test_
test_
test_
ubuntu_
NetworkManage
test_
test_
NetworkManage
test_
test_
test_
test_
test_nm_offline ... [OK]
test_
test_
test_
test_
test_
ubuntu_sso.tests
TestCase
runTest ... [OK]
ubuntu_
TestConnection
test_
test_
test_
test_
- 884. By Natalia Bidart
-
Adapting mock so it works with LANG=C.
Preview Diff
1 | === modified file 'setup.py' | |||
2 | --- setup.py 2012-02-14 20:49:45 +0000 | |||
3 | +++ setup.py 2012-02-18 14:14:18 +0000 | |||
4 | @@ -153,11 +153,6 @@ | |||
5 | 153 | 153 | ||
6 | 154 | def run(self): | 154 | def run(self): |
7 | 155 | """Execute the command.""" | 155 | """Execute the command.""" |
8 | 156 | # pylint: disable=W0703 | ||
9 | 157 | try: | ||
10 | 158 | self._wrapuic() | ||
11 | 159 | except Exception, e: | ||
12 | 160 | self.warn("Error wrapping uic to use gettext: %s" % e) | ||
13 | 161 | basepath = os.path.join('data', 'qt') | 156 | basepath = os.path.join('data', 'qt') |
14 | 162 | # TODO: build the resource files so that we can include them | 157 | # TODO: build the resource files so that we can include them |
15 | 163 | #self.build_rc(os.path.join(basepath, 'icons_rc.py'), | 158 | #self.build_rc(os.path.join(basepath, 'icons_rc.py'), |
16 | @@ -172,40 +167,6 @@ | |||
17 | 172 | 167 | ||
18 | 173 | build_extra.build_extra.run(self) | 168 | build_extra.build_extra.run(self) |
19 | 174 | 169 | ||
20 | 175 | # pylint: disable=E1002 | ||
21 | 176 | _wrappeduic = False | ||
22 | 177 | |||
23 | 178 | @classmethod | ||
24 | 179 | def _wrapuic(cls): | ||
25 | 180 | """Wrap uic to use gettext's _() in place of tr()""" | ||
26 | 181 | if cls._wrappeduic: | ||
27 | 182 | return | ||
28 | 183 | |||
29 | 184 | from PyQt4.uic.Compiler import compiler, qtproxies, indenter | ||
30 | 185 | |||
31 | 186 | # pylint: disable=C0103 | ||
32 | 187 | class _UICompiler(compiler.UICompiler): | ||
33 | 188 | """Speciallized compiler for qt .ui files.""" | ||
34 | 189 | def createToplevelWidget(self, classname, widgetname): | ||
35 | 190 | o = indenter.getIndenter() | ||
36 | 191 | o.level = 0 | ||
37 | 192 | o.write('from gettext import gettext as _') | ||
38 | 193 | return super(_UICompiler, self).createToplevelWidget(classname, | ||
39 | 194 | widgetname) | ||
40 | 195 | compiler.UICompiler = _UICompiler | ||
41 | 196 | |||
42 | 197 | class _i18n_string(qtproxies.i18n_string): | ||
43 | 198 | """Provide a translated text.""" | ||
44 | 199 | |||
45 | 200 | def __str__(self): | ||
46 | 201 | return "_('%s')" % self.string.encode('string-escape') | ||
47 | 202 | |||
48 | 203 | qtproxies.i18n_string = _i18n_string | ||
49 | 204 | |||
50 | 205 | cls._wrappeduic = True | ||
51 | 206 | # pylint: enable=C0103 | ||
52 | 207 | # pylint: enable=E1002 | ||
53 | 208 | |||
54 | 209 | 170 | ||
55 | 210 | class SSOClean(DistUtilsExtra.auto.clean_build_tree): | 171 | class SSOClean(DistUtilsExtra.auto.clean_build_tree): |
56 | 211 | """Class to clean up after the build.""" | 172 | """Class to clean up after the build.""" |
57 | 212 | 173 | ||
58 | === modified file 'ubuntu_sso/credentials.py' | |||
59 | --- ubuntu_sso/credentials.py 2012-02-11 19:25:01 +0000 | |||
60 | +++ ubuntu_sso/credentials.py 2012-02-18 14:14:18 +0000 | |||
61 | @@ -148,7 +148,9 @@ | |||
62 | 148 | value = getattr(self, arg) | 148 | value = getattr(self, arg) |
63 | 149 | if value: | 149 | if value: |
64 | 150 | args.append('--%s' % arg) | 150 | args.append('--%s' % arg) |
66 | 151 | args.append("%s" % str(value)) | 151 | if not isinstance(value, basestring): |
67 | 152 | value = str(value) | ||
68 | 153 | args.append(value) | ||
69 | 152 | 154 | ||
70 | 153 | if login_only: | 155 | if login_only: |
71 | 154 | args.append('--login_only') | 156 | args.append('--login_only') |
72 | 155 | 157 | ||
73 | === modified file 'ubuntu_sso/gtk/gui.py' | |||
74 | --- ubuntu_sso/gtk/gui.py 2012-02-11 19:25:01 +0000 | |||
75 | +++ ubuntu_sso/gtk/gui.py 2012-02-18 14:14:18 +0000 | |||
76 | @@ -111,6 +111,7 @@ | |||
77 | 111 | # To be replaced by values from the theme (LP: #616526) | 111 | # To be replaced by values from the theme (LP: #616526) |
78 | 112 | HELP_TEXT_COLOR = parse_color("#bfbfbf") | 112 | HELP_TEXT_COLOR = parse_color("#bfbfbf") |
79 | 113 | WARNING_TEXT_COLOR = parse_color("red") | 113 | WARNING_TEXT_COLOR = parse_color("red") |
80 | 114 | LARGE_MARKUP = u'<span size="x-large">%s</span>' | ||
81 | 114 | 115 | ||
82 | 115 | 116 | ||
83 | 116 | def log_call(f): | 117 | def log_call(f): |
84 | @@ -173,9 +174,9 @@ | |||
85 | 173 | 174 | ||
86 | 174 | def get_text(self): | 175 | def get_text(self): |
87 | 175 | """Get text only if it's not the label nor empty.""" | 176 | """Get text only if it's not the label nor empty.""" |
89 | 176 | result = super(LabeledEntry, self).get_text() | 177 | result = super(LabeledEntry, self).get_text().decode('utf8') |
90 | 177 | if result == self.label or result.isspace(): | 178 | if result == self.label or result.isspace(): |
92 | 178 | result = '' | 179 | result = u'' |
93 | 179 | return result | 180 | return result |
94 | 180 | 181 | ||
95 | 181 | def set_warning(self, warning_msg): | 182 | def set_warning(self, warning_msg): |
96 | @@ -209,10 +210,10 @@ | |||
97 | 209 | self._done = False # whether the whole process was completed or not | 210 | self._done = False # whether the whole process was completed or not |
98 | 210 | 211 | ||
99 | 211 | self.app_name = app_name | 212 | self.app_name = app_name |
104 | 212 | self.app_label = '<b>%s</b>' % self.app_name | 213 | self.app_label = u'<b>%s</b>' % self.app_name |
105 | 213 | self.ping_url = kwargs.get('ping_url', '') | 214 | self.ping_url = kwargs.get('ping_url', u'') |
106 | 214 | self.tc_url = kwargs.get('tc_url', '') | 215 | self.tc_url = kwargs.get('tc_url', u'') |
107 | 215 | self.help_text = kwargs.get('help_text', '') | 216 | self.help_text = kwargs.get('help_text', u'') |
108 | 216 | self.login_only = kwargs.get('login_only', False) | 217 | self.login_only = kwargs.get('login_only', False) |
109 | 217 | window_id = kwargs.get('window_id', 0) | 218 | window_id = kwargs.get('window_id', 0) |
110 | 218 | self.close_callback = kwargs.get('close_callback', NO_OP) | 219 | self.close_callback = kwargs.get('close_callback', NO_OP) |
111 | @@ -338,15 +339,14 @@ | |||
112 | 338 | def success_vbox(self): | 339 | def success_vbox(self): |
113 | 339 | """The success page.""" | 340 | """The success page.""" |
114 | 340 | message = SUCCESS % {'app_name': self.app_name} | 341 | message = SUCCESS % {'app_name': self.app_name} |
116 | 341 | message = '<span size="x-large">%s</span>' % message | 342 | message = LARGE_MARKUP % message |
117 | 342 | self.finish_vbox.label.set_markup(message) | 343 | self.finish_vbox.label.set_markup(message) |
118 | 343 | return self.finish_vbox | 344 | return self.finish_vbox |
119 | 344 | 345 | ||
120 | 345 | @property | 346 | @property |
121 | 346 | def error_vbox(self): | 347 | def error_vbox(self): |
122 | 347 | """The error page.""" | 348 | """The error page.""" |
125 | 348 | self.finish_vbox.label.set_markup('<span size="x-large">%s</span>' % | 349 | self.finish_vbox.label.set_markup(LARGE_MARKUP % ERROR) |
124 | 349 | ERROR) | ||
126 | 350 | return self.finish_vbox | 350 | return self.finish_vbox |
127 | 351 | 351 | ||
128 | 352 | # helpers | 352 | # helpers |
129 | @@ -362,7 +362,7 @@ | |||
130 | 362 | result = f(app_name, *args, **kwargs) | 362 | result = f(app_name, *args, **kwargs) |
131 | 363 | else: | 363 | else: |
132 | 364 | logger.info('%s: ignoring call since received app_name '\ | 364 | logger.info('%s: ignoring call since received app_name '\ |
134 | 365 | '"%s" (expected "%s")', | 365 | '%r (expected %r)', |
135 | 366 | f.__name__, app_name, self.app_name) | 366 | f.__name__, app_name, self.app_name) |
136 | 367 | return result | 367 | return result |
137 | 368 | 368 | ||
138 | @@ -459,8 +459,7 @@ | |||
139 | 459 | 459 | ||
140 | 460 | def _set_header(self, header): | 460 | def _set_header(self, header): |
141 | 461 | """Set 'header' as the window title and header.""" | 461 | """Set 'header' as the window title and header.""" |
144 | 462 | markup = '<span size="x-large">%s</span>' | 462 | self.header_label.set_markup(LARGE_MARKUP % header) |
143 | 463 | self.header_label.set_markup(markup % header) | ||
145 | 464 | self.window.set_title(self.header_label.get_text()) # avoid markup | 463 | self.window.set_title(self.header_label.get_text()) # avoid markup |
146 | 465 | 464 | ||
147 | 466 | def _set_current_page(self, current_page, warning_text=None): | 465 | def _set_current_page(self, current_page, warning_text=None): |
148 | @@ -792,9 +791,8 @@ | |||
149 | 792 | f = self.backend.register_user | 791 | f = self.backend.register_user |
150 | 793 | error_handler = partial(self._handle_error, f, | 792 | error_handler = partial(self._handle_error, f, |
151 | 794 | self.on_user_registration_error) | 793 | self.on_user_registration_error) |
155 | 795 | f(unicode(self.app_name), email1.decode('utf8'), | 794 | f(self.app_name, self.user_email, self.user_password, name, |
156 | 796 | password1.decode('utf8'), name.decode('utf8'), | 795 | self._captcha_id, captcha_solution, |
154 | 797 | unicode(self._captcha_id), captcha_solution.decode('utf8'), | ||
157 | 798 | reply_handler=NO_OP, error_handler=error_handler) | 796 | reply_handler=NO_OP, error_handler=error_handler) |
158 | 799 | 797 | ||
159 | 800 | def on_verify_token_button_clicked(self, *args, **kwargs): | 798 | def on_verify_token_button_clicked(self, *args, **kwargs): |
160 | @@ -1035,7 +1033,7 @@ | |||
161 | 1035 | """Captcha image has been generated and is available to be shown.""" | 1033 | """Captcha image has been generated and is available to be shown.""" |
162 | 1036 | if captcha_id is None: | 1034 | if captcha_id is None: |
163 | 1037 | logger.warning('on_captcha_generated: captcha_id is None for ' | 1035 | logger.warning('on_captcha_generated: captcha_id is None for ' |
165 | 1038 | 'app_name "%s".', app_name) | 1036 | 'app_name %r.', app_name) |
166 | 1039 | self._captcha_id = captcha_id | 1037 | self._captcha_id = captcha_id |
167 | 1040 | self._set_captcha_image() | 1038 | self._set_captcha_image() |
168 | 1041 | 1039 | ||
169 | 1042 | 1040 | ||
170 | === modified file 'ubuntu_sso/gtk/tests/test_gui.py' | |||
171 | --- ubuntu_sso/gtk/tests/test_gui.py 2012-02-11 01:51:57 +0000 | |||
172 | +++ ubuntu_sso/gtk/tests/test_gui.py 2012-02-18 14:14:18 +0000 | |||
173 | @@ -165,7 +165,7 @@ | |||
174 | 165 | tmp = Gdk.RGBA() | 165 | tmp = Gdk.RGBA() |
175 | 166 | assert tmp.parse(gdk_color.to_string()) | 166 | assert tmp.parse(gdk_color.to_string()) |
176 | 167 | 167 | ||
178 | 168 | msg = 'Text color must be "%s" (got "%s" instead).' | 168 | msg = 'Text color must be %r (got %r instead).' |
179 | 169 | self.assertEqual(rgba_color, tmp, msg % (rgba_color, tmp)) | 169 | self.assertEqual(rgba_color, tmp, msg % (rgba_color, tmp)) |
180 | 170 | 170 | ||
181 | 171 | def assert_backend_called(self, method, *args, **kwargs): | 171 | def assert_backend_called(self, method, *args, **kwargs): |
182 | @@ -211,7 +211,7 @@ | |||
183 | 211 | def assert_correct_label(self): | 211 | def assert_correct_label(self): |
184 | 212 | """Check that the entry has the correct label.""" | 212 | """Check that the entry has the correct label.""" |
185 | 213 | # text content is correct | 213 | # text content is correct |
187 | 214 | msg = 'Text content must be "%s" (got "%s" instead).' | 214 | msg = 'Text content must be %r (got %r instead).' |
188 | 215 | expected = self.label | 215 | expected = self.label |
189 | 216 | actual = super(gui.LabeledEntry, self.entry).get_text() | 216 | actual = super(gui.LabeledEntry, self.entry).get_text() |
190 | 217 | self.assertEqual(expected, actual, msg % (expected, actual)) | 217 | self.assertEqual(expected, actual, msg % (expected, actual)) |
191 | @@ -231,7 +231,7 @@ | |||
192 | 231 | 231 | ||
193 | 232 | def test_tooltip(self): | 232 | def test_tooltip(self): |
194 | 233 | """Entry have the correct tooltip.""" | 233 | """Entry have the correct tooltip.""" |
196 | 234 | msg = 'Tooltip must be "%s" (got "%s" instead).' | 234 | msg = 'Tooltip must be %r (got %r instead).' |
197 | 235 | expected = self.label | 235 | expected = self.label |
198 | 236 | actual = self.entry.get_tooltip_text() | 236 | actual = self.entry.get_tooltip_text() |
199 | 237 | # tooltip is correct | 237 | # tooltip is correct |
200 | @@ -404,7 +404,7 @@ | |||
201 | 404 | 404 | ||
202 | 405 | def assert_entries_are_packed_to_ui(self, container_name, entries): | 405 | def assert_entries_are_packed_to_ui(self, container_name, entries): |
203 | 406 | """Every entry is properly packed in the ui 'container_name'.""" | 406 | """Every entry is properly packed in the ui 'container_name'.""" |
205 | 407 | msg = 'Entry "%s" must be packed in "%s" but is not.' | 407 | msg = 'Entry %r must be packed in %r but is not.' |
206 | 408 | container = getattr(self.ui, container_name) | 408 | container = getattr(self.ui, container_name) |
207 | 409 | for kind in entries: | 409 | for kind in entries: |
208 | 410 | name = '%s_entry' % kind | 410 | name = '%s_entry' % kind |
209 | @@ -414,7 +414,7 @@ | |||
210 | 414 | 414 | ||
211 | 415 | def assert_warnings_visibility(self, visible=False): | 415 | def assert_warnings_visibility(self, visible=False): |
212 | 416 | """Every warning label should be 'visible'.""" | 416 | """Every warning label should be 'visible'.""" |
214 | 417 | msg = '"%s" should have %sempty content.' | 417 | msg = '%r should have %sempty content.' |
215 | 418 | for name in self.ui.widgets: | 418 | for name in self.ui.widgets: |
216 | 419 | widget = getattr(self.ui, name) | 419 | widget = getattr(self.ui, name) |
217 | 420 | if 'warning' in name: | 420 | if 'warning' in name: |
218 | @@ -429,7 +429,7 @@ | |||
219 | 429 | self.assertTrue(label.get_property('visible')) | 429 | self.assertTrue(label.get_property('visible')) |
220 | 430 | 430 | ||
221 | 431 | # warning content is correct | 431 | # warning content is correct |
223 | 432 | actual = label.get_text() | 432 | actual = label.get_text().decode('utf-8') |
224 | 433 | self.assertEqual(actual, message) | 433 | self.assertEqual(actual, message) |
225 | 434 | 434 | ||
226 | 435 | # content color is correct | 435 | # content color is correct |
227 | @@ -547,7 +547,7 @@ | |||
228 | 547 | 547 | ||
229 | 548 | def test_initial_text_for_entries(self): | 548 | def test_initial_text_for_entries(self): |
230 | 549 | """Entries have the correct text at startup.""" | 549 | """Entries have the correct text at startup.""" |
232 | 550 | msg = 'Text for "%s" must be "%s" (got "%s" instead).' | 550 | msg = 'Text for %r must be %r (got %r instead).' |
233 | 551 | for name in self.ui.entries: | 551 | for name in self.ui.entries: |
234 | 552 | entry = getattr(self.ui, name) | 552 | entry = getattr(self.ui, name) |
235 | 553 | expected = getattr(gui.utils.ui, name.upper()) | 553 | expected = getattr(gui.utils.ui, name.upper()) |
236 | @@ -557,14 +557,14 @@ | |||
237 | 557 | 557 | ||
238 | 558 | def test_entries_activates_default(self): | 558 | def test_entries_activates_default(self): |
239 | 559 | """Entries have the activates default prop set.""" | 559 | """Entries have the activates default prop set.""" |
241 | 560 | msg = '"%s" must have activates_default set to True.' | 560 | msg = '%r must have activates_default set to True.' |
242 | 561 | for name in self.ui.entries: | 561 | for name in self.ui.entries: |
243 | 562 | entry = getattr(self.ui, name) | 562 | entry = getattr(self.ui, name) |
244 | 563 | self.assertTrue(entry.get_activates_default(), msg % (name,)) | 563 | self.assertTrue(entry.get_activates_default(), msg % (name,)) |
245 | 564 | 564 | ||
246 | 565 | def test_password_fields_are_password(self): | 565 | def test_password_fields_are_password(self): |
247 | 566 | """Password fields have the is_password flag set.""" | 566 | """Password fields have the is_password flag set.""" |
249 | 567 | msg = '"%s" should be a password LabeledEntry instance.' | 567 | msg = '%r should be a password LabeledEntry instance.' |
250 | 568 | passwords = filter(lambda name: 'password' in name, | 568 | passwords = filter(lambda name: 'password' in name, |
251 | 569 | self.ui.entries) | 569 | self.ui.entries) |
252 | 570 | for name in passwords: | 570 | for name in passwords: |
253 | @@ -578,7 +578,7 @@ | |||
254 | 578 | def test_cancel_buttons_close_window(self): | 578 | def test_cancel_buttons_close_window(self): |
255 | 579 | """Every cancel button should close the window when clicked.""" | 579 | """Every cancel button should close the window when clicked.""" |
256 | 580 | self.patch(self.ui.backend, 'disconnect_from_signal', lambda *a: None) | 580 | self.patch(self.ui.backend, 'disconnect_from_signal', lambda *a: None) |
258 | 581 | msg = '"%s" should close the window when clicked.' | 581 | msg = '%r should close the window when clicked.' |
259 | 582 | buttons = filter(lambda name: 'cancel_button' in name or | 582 | buttons = filter(lambda name: 'cancel_button' in name or |
260 | 583 | 'close_button' in name, self.ui.widgets) | 583 | 'close_button' in name, self.ui.widgets) |
261 | 584 | for name in buttons: | 584 | for name in buttons: |
262 | @@ -597,15 +597,16 @@ | |||
263 | 597 | self.ui.finish_success() | 597 | self.ui.finish_success() |
264 | 598 | self.assert_pages_visibility(finish=True) | 598 | self.assert_pages_visibility(finish=True) |
265 | 599 | self.assertEqual(gui.SUCCESS % {'app_name': APP_NAME}, | 599 | self.assertEqual(gui.SUCCESS % {'app_name': APP_NAME}, |
268 | 600 | self.ui.finish_vbox.label.get_text()) | 600 | self.ui.finish_vbox.label.get_text().decode('utf8')) |
269 | 601 | result = self.ui.finish_vbox.label.get_text() | 601 | result = self.ui.finish_vbox.label.get_text().decode('utf8') |
270 | 602 | self.assertTrue(self.ui.app_name in result) | 602 | self.assertTrue(self.ui.app_name in result) |
271 | 603 | 603 | ||
272 | 604 | def test_finish_error_shows_error_page(self): | 604 | def test_finish_error_shows_error_page(self): |
273 | 605 | """When calling 'finish_error' the error page is shown.""" | 605 | """When calling 'finish_error' the error page is shown.""" |
274 | 606 | self.ui.finish_error() | 606 | self.ui.finish_error() |
275 | 607 | self.assert_pages_visibility(finish=True) | 607 | self.assert_pages_visibility(finish=True) |
277 | 608 | self.assertEqual(gui.ERROR, self.ui.finish_vbox.label.get_text()) | 608 | self.assertEqual(gui.ERROR, |
278 | 609 | self.ui.finish_vbox.label.get_text().decode('utf8')) | ||
279 | 609 | 610 | ||
280 | 610 | 611 | ||
281 | 611 | class SetTransientForTestCase(UbuntuSSOClientTestCase): | 612 | class SetTransientForTestCase(UbuntuSSOClientTestCase): |
282 | @@ -649,9 +650,9 @@ | |||
283 | 649 | 650 | ||
284 | 650 | def test_initial_text_for_header_label(self): | 651 | def test_initial_text_for_header_label(self): |
285 | 651 | """The header must have the correct text at startup.""" | 652 | """The header must have the correct text at startup.""" |
287 | 652 | msg = 'Text for the header must be "%s" (got "%s" instead).' | 653 | msg = 'Text for the header must be %r (got %r instead).' |
288 | 653 | expected = gui.JOIN_HEADER_LABEL % {'app_name': APP_NAME} | 654 | expected = gui.JOIN_HEADER_LABEL % {'app_name': APP_NAME} |
290 | 654 | actual = self.ui.header_label.get_text() | 655 | actual = self.ui.header_label.get_text().decode('utf8') |
291 | 655 | # text content is correct | 656 | # text content is correct |
292 | 656 | self.assertEqual(expected, actual, msg % (expected, actual)) | 657 | self.assertEqual(expected, actual, msg % (expected, actual)) |
293 | 657 | 658 | ||
294 | @@ -670,26 +671,26 @@ | |||
295 | 670 | 671 | ||
296 | 671 | def test_initial_texts_for_checkbuttons(self): | 672 | def test_initial_texts_for_checkbuttons(self): |
297 | 672 | """Check buttons have the correct text at startup.""" | 673 | """Check buttons have the correct text at startup.""" |
299 | 673 | msg = 'Text for "%s" must be "%s" (got "%s" instead).' | 674 | msg = 'Text for %r must be %r (got %r instead).' |
300 | 674 | expected = gui.YES_TO_UPDATES % {'app_name': APP_NAME} | 675 | expected = gui.YES_TO_UPDATES % {'app_name': APP_NAME} |
302 | 675 | actual = self.ui.yes_to_updates_checkbutton.get_label() | 676 | actual = self.ui.yes_to_updates_checkbutton.get_label().decode('utf8') |
303 | 676 | self.assertEqual(expected, actual, msg % ('yes_to_updates_checkbutton', | 677 | self.assertEqual(expected, actual, msg % ('yes_to_updates_checkbutton', |
304 | 677 | expected, actual)) | 678 | expected, actual)) |
305 | 678 | expected = gui.YES_TO_TC % {'app_name': APP_NAME} | 679 | expected = gui.YES_TO_TC % {'app_name': APP_NAME} |
307 | 679 | actual = self.ui.yes_to_tc_checkbutton.get_label() | 680 | actual = self.ui.yes_to_tc_checkbutton.get_label().decode('utf8') |
308 | 680 | self.assertEqual(expected, actual, | 681 | self.assertEqual(expected, actual, |
309 | 681 | msg % ('yes_to_tc_checkbutton', expected, actual)) | 682 | msg % ('yes_to_tc_checkbutton', expected, actual)) |
310 | 682 | 683 | ||
311 | 683 | def test_checkbutton_is_checked_at_startup(self): | 684 | def test_checkbutton_is_checked_at_startup(self): |
312 | 684 | """Checkbuttons are checked by default.""" | 685 | """Checkbuttons are checked by default.""" |
314 | 685 | msg = '"%s" is checked by default.' | 686 | msg = '%r is checked by default.' |
315 | 686 | name = 'yes_to_updates_checkbutton' | 687 | name = 'yes_to_updates_checkbutton' |
316 | 687 | widget = getattr(self.ui, name) | 688 | widget = getattr(self.ui, name) |
317 | 688 | self.assertTrue(widget.get_active(), msg % name) | 689 | self.assertTrue(widget.get_active(), msg % name) |
318 | 689 | 690 | ||
319 | 690 | def test_checkbutton_isnt_checked_at_startup(self): | 691 | def test_checkbutton_isnt_checked_at_startup(self): |
320 | 691 | """Checkbuttons are checked by default.""" | 692 | """Checkbuttons are checked by default.""" |
322 | 692 | msg = '"%s" is checked by default.' | 693 | msg = '%r is checked by default.' |
323 | 693 | name = 'yes_to_tc_checkbutton' | 694 | name = 'yes_to_tc_checkbutton' |
324 | 694 | widget = getattr(self.ui, name) | 695 | widget = getattr(self.ui, name) |
325 | 695 | self.assertFalse(widget.get_active(), msg % name) | 696 | self.assertFalse(widget.get_active(), msg % name) |
326 | @@ -732,7 +733,8 @@ | |||
327 | 732 | 'the processing spinner should be active.') | 733 | 'the processing spinner should be active.') |
328 | 733 | self.assertTrue(label.get_property('visible'), | 734 | self.assertTrue(label.get_property('visible'), |
329 | 734 | 'the processing label should be visible.') | 735 | 'the processing label should be visible.') |
331 | 735 | self.assertEqual(label.get_text(), gui.ONE_MOMENT_PLEASE, | 736 | self.assertEqual(label.get_text().decode('utf8'), |
332 | 737 | gui.ONE_MOMENT_PLEASE, | ||
333 | 736 | 'the processing label text must be correct.') | 738 | 'the processing label text must be correct.') |
334 | 737 | 739 | ||
335 | 738 | def test_captcha_image_is_not_visible_at_startup(self): | 740 | def test_captcha_image_is_not_visible_at_startup(self): |
336 | @@ -775,7 +777,7 @@ | |||
337 | 775 | 'the captcha_loading spinner should be active.') | 777 | 'the captcha_loading spinner should be active.') |
338 | 776 | self.assertTrue(label.get_property('visible'), | 778 | self.assertTrue(label.get_property('visible'), |
339 | 777 | 'the captcha_loading label should be visible.') | 779 | 'the captcha_loading label should be visible.') |
341 | 778 | self.assertEqual(label.get_text(), gui.LOADING, | 780 | self.assertEqual(label.get_text().decode('utf8'), gui.LOADING, |
342 | 779 | 'the captcha_loading label text must be correct.') | 781 | 'the captcha_loading label text must be correct.') |
343 | 780 | 782 | ||
344 | 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): |
345 | @@ -814,7 +816,7 @@ | |||
346 | 814 | def test_on_captcha_generated_logs_captcha_id_when_none(self): | 816 | def test_on_captcha_generated_logs_captcha_id_when_none(self): |
347 | 815 | """If the captcha id is None, a warning is logged.""" | 817 | """If the captcha id is None, a warning is logged.""" |
348 | 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) |
350 | 817 | self.assertTrue(self.memento.check(logging.WARNING, APP_NAME)) | 819 | self.assertTrue(self.memento.check(logging.WARNING, repr(APP_NAME))) |
351 | 818 | self.assertTrue(self.memento.check(logging.WARNING, | 820 | self.assertTrue(self.memento.check(logging.WARNING, |
352 | 819 | 'captcha_id is None')) | 821 | 'captcha_id is None')) |
353 | 820 | 822 | ||
354 | @@ -837,7 +839,7 @@ | |||
355 | 837 | 839 | ||
356 | 838 | def test_login_button_has_correct_wording(self): | 840 | def test_login_button_has_correct_wording(self): |
357 | 839 | """The sign in button has the proper wording.""" | 841 | """The sign in button has the proper wording.""" |
359 | 840 | actual = self.ui.login_button.get_label() | 842 | actual = self.ui.login_button.get_label().decode('utf8') |
360 | 841 | self.assertEqual(gui.LOGIN_BUTTON_LABEL, actual) | 843 | self.assertEqual(gui.LOGIN_BUTTON_LABEL, actual) |
361 | 842 | 844 | ||
362 | 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): |
363 | @@ -870,7 +872,7 @@ | |||
364 | 870 | """When captcha was retrieved after error, the warning is removed.""" | 872 | """When captcha was retrieved after error, the warning is removed.""" |
365 | 871 | self.ui.on_captcha_generation_error(APP_NAME, error=self.error) | 873 | self.ui.on_captcha_generation_error(APP_NAME, error=self.error) |
366 | 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) |
368 | 873 | self.assertEqual(self.ui.warning_label.get_text(), '') | 875 | self.assertEqual(self.ui.warning_label.get_text().decode('utf8'), '') |
369 | 874 | 876 | ||
370 | 875 | 877 | ||
371 | 876 | class NoTermsAndConditionsTestCase(UbuntuSSOClientTestCase): | 878 | class NoTermsAndConditionsTestCase(UbuntuSSOClientTestCase): |
372 | @@ -953,12 +955,13 @@ | |||
373 | 953 | 955 | ||
374 | 954 | def test_tc_button_has_the_proper_wording(self): | 956 | def test_tc_button_has_the_proper_wording(self): |
375 | 955 | """Terms & Conditions has the proper wording.""" | 957 | """Terms & Conditions has the proper wording.""" |
377 | 956 | self.assertEqual(self.ui.tc_button.get_label(), gui.TC_BUTTON) | 958 | self.assertEqual(self.ui.tc_button.get_label().decode('utf8'), |
378 | 959 | gui.TC_BUTTON) | ||
379 | 957 | 960 | ||
380 | 958 | def test_tc_has_no_help_text(self): | 961 | def test_tc_has_no_help_text(self): |
381 | 959 | """The help text is removed.""" | 962 | """The help text is removed.""" |
382 | 960 | self.ui.on_tc_browser_notify_load_status(self.browser) | 963 | self.ui.on_tc_browser_notify_load_status(self.browser) |
384 | 961 | self.assertEqual('', self.ui.help_label.get_text()) | 964 | self.assertEqual('', self.ui.help_label.get_text().decode('utf8')) |
385 | 962 | 965 | ||
386 | 963 | def test_tc_browser_opens_the_proper_url(self): | 966 | def test_tc_browser_opens_the_proper_url(self): |
387 | 964 | """Terms & Conditions browser shows the proper uri.""" | 967 | """Terms & Conditions browser shows the proper uri.""" |
388 | @@ -1115,8 +1118,8 @@ | |||
389 | 1115 | 1118 | ||
390 | 1116 | def test_help_label_display_correct_wording(self): | 1119 | def test_help_label_display_correct_wording(self): |
391 | 1117 | """The help_label display VERIFY_EMAIL_LABEL.""" | 1120 | """The help_label display VERIFY_EMAIL_LABEL.""" |
394 | 1118 | msg = 'help_label must read "%s" (got "%s" instead).' | 1121 | msg = 'help_label must read %r (got %r instead).' |
395 | 1119 | actual = self.ui.help_label.get_label() | 1122 | actual = self.ui.help_label.get_label().decode('utf8') |
396 | 1120 | expected = gui.VERIFY_EMAIL_LABEL % {'app_name': APP_NAME, | 1123 | expected = gui.VERIFY_EMAIL_LABEL % {'app_name': APP_NAME, |
397 | 1121 | 'email': EMAIL} | 1124 | 'email': EMAIL} |
398 | 1122 | self.assertEqual(expected, actual, msg % (expected, actual)) | 1125 | self.assertEqual(expected, actual, msg % (expected, actual)) |
399 | @@ -1160,7 +1163,7 @@ | |||
400 | 1160 | """On email validated the help text is not removed.""" | 1163 | """On email validated the help text is not removed.""" |
401 | 1161 | self.ui.on_email_validated(app_name=APP_NAME, email=EMAIL) | 1164 | self.ui.on_email_validated(app_name=APP_NAME, email=EMAIL) |
402 | 1162 | self.assertEqual(self.ui.verify_email_vbox.help_text, | 1165 | self.assertEqual(self.ui.verify_email_vbox.help_text, |
404 | 1163 | self.ui.help_label.get_label()) | 1166 | self.ui.help_label.get_label().decode('utf8')) |
405 | 1164 | 1167 | ||
406 | 1165 | def test_on_email_validation_error_verify_email_is_shown(self): | 1168 | def test_on_email_validation_error_verify_email_is_shown(self): |
407 | 1166 | """On email validation error, the verify_email page is shown.""" | 1169 | """On email validation error, the verify_email page is shown.""" |
408 | @@ -1186,16 +1189,16 @@ | |||
409 | 1186 | def test_success_label_is_correct(self): | 1189 | def test_success_label_is_correct(self): |
410 | 1187 | """The success message is correct.""" | 1190 | """The success message is correct.""" |
411 | 1188 | self.assertEqual(gui.SUCCESS % {'app_name': APP_NAME}, | 1191 | self.assertEqual(gui.SUCCESS % {'app_name': APP_NAME}, |
414 | 1189 | self.ui.success_vbox.label.get_text()) | 1192 | self.ui.success_vbox.label.get_text().decode('utf8')) |
415 | 1190 | markup = self.ui.success_vbox.label.get_label() | 1193 | markup = self.ui.success_vbox.label.get_label().decode('utf8') |
416 | 1191 | self.assertTrue('<span size="x-large">' in markup) | 1194 | self.assertTrue('<span size="x-large">' in markup) |
417 | 1192 | self.assertTrue(self.ui.app_name in markup) | 1195 | self.assertTrue(self.ui.app_name in markup) |
418 | 1193 | 1196 | ||
419 | 1194 | def test_error_label_is_correct(self): | 1197 | def test_error_label_is_correct(self): |
420 | 1195 | """The error message is correct.""" | 1198 | """The error message is correct.""" |
421 | 1196 | self.assertEqual(gui.ERROR, | 1199 | self.assertEqual(gui.ERROR, |
424 | 1197 | self.ui.error_vbox.label.get_text()) | 1200 | self.ui.error_vbox.label.get_text().decode('utf8')) |
425 | 1198 | markup = self.ui.error_vbox.label.get_label() | 1201 | markup = self.ui.error_vbox.label.get_label().decode('utf8') |
426 | 1199 | self.assertTrue('<span size="x-large">' in markup) | 1202 | self.assertTrue('<span size="x-large">' in markup) |
427 | 1200 | 1203 | ||
428 | 1201 | def test_on_finish_close_button_clicked_closes_window(self): | 1204 | def test_on_finish_close_button_clicked_closes_window(self): |
429 | @@ -1346,7 +1349,7 @@ | |||
430 | 1346 | """Password help text is correctly displayed.""" | 1349 | """Password help text is correctly displayed.""" |
431 | 1347 | self.assertTrue(self.ui.password_help_label.get_property('visible'), | 1350 | self.assertTrue(self.ui.password_help_label.get_property('visible'), |
432 | 1348 | 'password help text is visible.') | 1351 | 'password help text is visible.') |
434 | 1349 | self.assertEqual(self.ui.password_help_label.get_text(), | 1352 | self.assertEqual(self.ui.password_help_label.get_text().decode('utf8'), |
435 | 1350 | gui.PASSWORD_HELP) | 1353 | gui.PASSWORD_HELP) |
436 | 1351 | self.assertNotIn('register_user', self.ui.backend._called) | 1354 | self.assertNotIn('register_user', self.ui.backend._called) |
437 | 1352 | 1355 | ||
438 | @@ -1436,16 +1439,16 @@ | |||
439 | 1436 | 1439 | ||
440 | 1437 | def test_initial_text_for_header_label(self): | 1440 | def test_initial_text_for_header_label(self): |
441 | 1438 | """The header must have the correct text when logging in.""" | 1441 | """The header must have the correct text when logging in.""" |
443 | 1439 | msg = 'Text for the header must be "%s" (got "%s" instead).' | 1442 | msg = 'Text for the header must be %r (got %r instead).' |
444 | 1440 | expected = gui.LOGIN_HEADER_LABEL % {'app_name': APP_NAME} | 1443 | expected = gui.LOGIN_HEADER_LABEL % {'app_name': APP_NAME} |
446 | 1441 | actual = self.ui.header_label.get_text() | 1444 | actual = self.ui.header_label.get_text().decode('utf8') |
447 | 1442 | self.assertEqual(expected, actual, msg % (expected, actual)) | 1445 | self.assertEqual(expected, actual, msg % (expected, actual)) |
448 | 1443 | 1446 | ||
449 | 1444 | def test_initial_text_for_help_label(self): | 1447 | def test_initial_text_for_help_label(self): |
450 | 1445 | """The help must have the correct text at startup.""" | 1448 | """The help must have the correct text at startup.""" |
452 | 1446 | msg = 'Text for the help must be "%s" (got "%s" instead).' | 1449 | msg = 'Text for the help must be %r (got %r instead).' |
453 | 1447 | expected = gui.CONNECT_HELP_LABEL % {'app_name': APP_NAME} | 1450 | expected = gui.CONNECT_HELP_LABEL % {'app_name': APP_NAME} |
455 | 1448 | actual = self.ui.help_label.get_text() | 1451 | actual = self.ui.help_label.get_text().decode('utf8') |
456 | 1449 | self.assertEqual(expected, actual, msg % (expected, actual)) | 1452 | self.assertEqual(expected, actual, msg % (expected, actual)) |
457 | 1450 | 1453 | ||
458 | 1451 | def test_entries_are_packed_to_ui_for_login(self): | 1454 | def test_entries_are_packed_to_ui_for_login(self): |
459 | @@ -1628,23 +1631,23 @@ | |||
460 | 1628 | 1631 | ||
461 | 1629 | def test_forgotten_password_button_has_the_proper_wording(self): | 1632 | def test_forgotten_password_button_has_the_proper_wording(self): |
462 | 1630 | """The forgotten_password_button has the proper wording.""" | 1633 | """The forgotten_password_button has the proper wording.""" |
465 | 1631 | self.assertEqual(self.ui.forgotten_password_button.get_label(), | 1634 | actual = self.ui.forgotten_password_button.get_label() |
466 | 1632 | gui.FORGOTTEN_PASSWORD_BUTTON) | 1635 | self.assertEqual(actual.decode('utf8'), gui.FORGOTTEN_PASSWORD_BUTTON) |
467 | 1633 | 1636 | ||
468 | 1634 | def test_on_forgotten_password_button_clicked_help_text(self): | 1637 | def test_on_forgotten_password_button_clicked_help_text(self): |
469 | 1635 | """Clicking forgotten_password_button the help is properly changed.""" | 1638 | """Clicking forgotten_password_button the help is properly changed.""" |
470 | 1636 | wanted = gui.REQUEST_PASSWORD_TOKEN_LABEL % {'app_name': APP_NAME} | 1639 | wanted = gui.REQUEST_PASSWORD_TOKEN_LABEL % {'app_name': APP_NAME} |
472 | 1637 | self.assertEqual(self.ui.help_label.get_text(), wanted) | 1640 | self.assertEqual(self.ui.help_label.get_text().decode('utf8'), wanted) |
473 | 1638 | 1641 | ||
474 | 1639 | def test_on_forgotten_password_button_clicked_header_label(self): | 1642 | def test_on_forgotten_password_button_clicked_header_label(self): |
475 | 1640 | """Clicking forgotten_password_button the title is properly changed.""" | 1643 | """Clicking forgotten_password_button the title is properly changed.""" |
477 | 1641 | self.assertEqual(self.ui.header_label.get_text(), | 1644 | self.assertEqual(self.ui.header_label.get_text().decode('utf8'), |
478 | 1642 | gui.RESET_PASSWORD) | 1645 | gui.RESET_PASSWORD) |
479 | 1643 | 1646 | ||
480 | 1644 | def test_on_forgotten_password_button_clicked_ok_button(self): | 1647 | def test_on_forgotten_password_button_clicked_ok_button(self): |
481 | 1645 | """Clicking forgotten_password_button the ok button reads 'Next'.""" | 1648 | """Clicking forgotten_password_button the ok button reads 'Next'.""" |
484 | 1646 | self.assertEqual(self.ui.request_password_token_ok_button.get_label(), | 1649 | actual = self.ui.request_password_token_ok_button.get_label() |
485 | 1647 | gui.NEXT) | 1650 | self.assertEqual(actual.decode('utf8'), gui.NEXT) |
486 | 1648 | 1651 | ||
487 | 1649 | def test_on_forgotten_password_button_clicked_morphs_window(self): | 1652 | def test_on_forgotten_password_button_clicked_morphs_window(self): |
488 | 1650 | """Clicking forgotten_password_button the proper page is shown.""" | 1653 | """Clicking forgotten_password_button the proper page is shown.""" |
489 | @@ -1691,7 +1694,7 @@ | |||
490 | 1691 | self.click_request_password_token_with_valid_data() | 1694 | self.click_request_password_token_with_valid_data() |
491 | 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) |
492 | 1693 | 1696 | ||
494 | 1694 | self.assertEqual(self.ui.help_label.get_text(), | 1697 | self.assertEqual(self.ui.help_label.get_text().decode('utf8'), |
495 | 1695 | gui.SET_NEW_PASSWORD_LABEL % {'email': EMAIL}) | 1698 | gui.SET_NEW_PASSWORD_LABEL % {'email': EMAIL}) |
496 | 1696 | 1699 | ||
497 | 1697 | def test_on_password_reset_token_sent_ok_button(self): | 1700 | def test_on_password_reset_token_sent_ok_button(self): |
498 | @@ -1699,8 +1702,8 @@ | |||
499 | 1699 | self.click_request_password_token_with_valid_data() | 1702 | self.click_request_password_token_with_valid_data() |
500 | 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) |
501 | 1701 | 1704 | ||
504 | 1702 | self.assertEqual(self.ui.set_new_password_ok_button.get_label(), | 1705 | actual = self.ui.set_new_password_ok_button.get_label() |
505 | 1703 | gui.RESET_PASSWORD) | 1706 | self.assertEqual(actual.decode('utf8'), gui.RESET_PASSWORD) |
506 | 1704 | 1707 | ||
507 | 1705 | def test_on_password_reset_error_shows_login_page(self): | 1708 | def test_on_password_reset_error_shows_login_page(self): |
508 | 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.""" |
509 | @@ -1872,8 +1875,8 @@ | |||
510 | 1872 | """Password help text is correctly displayed.""" | 1875 | """Password help text is correctly displayed.""" |
511 | 1873 | visible = self.ui.reset_password_help_label.get_property('visible') | 1876 | visible = self.ui.reset_password_help_label.get_property('visible') |
512 | 1874 | self.assertTrue(visible, 'password help text is visible.') | 1877 | self.assertTrue(visible, 'password help text is visible.') |
515 | 1875 | self.assertEqual(self.ui.reset_password_help_label.get_text(), | 1878 | actual = self.ui.reset_password_help_label.get_text() |
516 | 1876 | gui.PASSWORD_HELP) | 1879 | self.assertEqual(actual.decode('utf8'), gui.PASSWORD_HELP) |
517 | 1877 | self.assertNotIn('set_new_password', self.ui.backend._called) | 1880 | self.assertNotIn('set_new_password', self.ui.backend._called) |
518 | 1878 | 1881 | ||
519 | 1879 | def test_warning_is_shown_if_password_mismatch(self): | 1882 | def test_warning_is_shown_if_password_mismatch(self): |
520 | @@ -1951,7 +1954,7 @@ | |||
521 | 1951 | """Callbacks do nothing but logging when app_name doesn't match.""" | 1954 | """Callbacks do nothing but logging when app_name doesn't match.""" |
522 | 1952 | mismatch_app_name = self.ui.app_name * 2 | 1955 | mismatch_app_name = self.ui.app_name * 2 |
523 | 1953 | for method in self.ui._signals.itervalues(): | 1956 | for method in self.ui._signals.itervalues(): |
525 | 1954 | msgs = ('ignoring', method.__name__, mismatch_app_name) | 1957 | msgs = ('ignoring', method.__name__, repr(mismatch_app_name)) |
526 | 1955 | method(mismatch_app_name, 'dummy') | 1958 | method(mismatch_app_name, 'dummy') |
527 | 1956 | self.assertTrue(self.memento.check(logging.INFO, *msgs)) | 1959 | self.assertTrue(self.memento.check(logging.INFO, *msgs)) |
528 | 1957 | self.memento.records = [] | 1960 | self.memento.records = [] |
529 | @@ -2068,7 +2071,8 @@ | |||
530 | 2068 | 2071 | ||
531 | 2069 | def test_help_text_is_used(self): | 2072 | def test_help_text_is_used(self): |
532 | 2070 | """The passed help_text is used.""" | 2073 | """The passed help_text is used.""" |
534 | 2071 | self.assertEqual(self.ui.help_label.get_text(), HELP_TEXT) | 2074 | self.assertEqual(self.ui.help_label.get_text().decode('utf8'), |
535 | 2075 | HELP_TEXT) | ||
536 | 2072 | 2076 | ||
537 | 2073 | 2077 | ||
538 | 2074 | class ReturnCodeTestCase(UbuntuSSOClientTestCase): | 2078 | class ReturnCodeTestCase(UbuntuSSOClientTestCase): |
539 | @@ -2087,7 +2091,7 @@ | |||
540 | 2087 | def test_every_cancel_calls_proper_callback(self): | 2091 | def test_every_cancel_calls_proper_callback(self): |
541 | 2088 | """When any cancel button is clicked, USER_CANCELLATION is called.""" | 2092 | """When any cancel button is clicked, USER_CANCELLATION is called.""" |
542 | 2089 | self.patch(self.ui.backend, 'disconnect_from_signal', lambda *a: None) | 2093 | self.patch(self.ui.backend, 'disconnect_from_signal', lambda *a: None) |
544 | 2090 | msg = 'USER_CANCELLATION should be returned when "%s" is clicked.' | 2094 | msg = 'USER_CANCELLATION should be returned when %r is clicked.' |
545 | 2091 | buttons = filter(lambda name: 'cancel_button' in name, self.ui.widgets) | 2095 | buttons = filter(lambda name: 'cancel_button' in name, self.ui.widgets) |
546 | 2092 | for name in buttons: | 2096 | for name in buttons: |
547 | 2093 | widget = getattr(self.ui, name) | 2097 | widget = getattr(self.ui, name) |
548 | 2094 | 2098 | ||
549 | === modified file 'ubuntu_sso/keyring/tests/test_linux.py' | |||
550 | --- ubuntu_sso/keyring/tests/test_linux.py 2012-01-26 15:34:16 +0000 | |||
551 | +++ ubuntu_sso/keyring/tests/test_linux.py 2012-02-18 14:14:18 +0000 | |||
552 | @@ -26,7 +26,6 @@ | |||
553 | 26 | 26 | ||
554 | 27 | from ubuntu_sso import keyring as common_keyring | 27 | from ubuntu_sso import keyring as common_keyring |
555 | 28 | from ubuntu_sso.keyring import linux as keyring | 28 | from ubuntu_sso.keyring import linux as keyring |
556 | 29 | from ubuntu_sso.tests import APP_NAME | ||
557 | 30 | 29 | ||
558 | 31 | 30 | ||
559 | 32 | class MockItem(object): | 31 | class MockItem(object): |
560 | @@ -168,9 +167,9 @@ | |||
561 | 168 | sample_creds = {"name": "sample creds name"} | 167 | sample_creds = {"name": "sample creds name"} |
562 | 169 | kr = keyring.Keyring() | 168 | kr = keyring.Keyring() |
563 | 170 | self.patch(keyring, "get_token_name", keyring.get_old_token_name) | 169 | self.patch(keyring, "get_token_name", keyring.get_old_token_name) |
565 | 171 | yield kr.set_credentials(APP_NAME, sample_creds) | 170 | yield kr.set_credentials("app name", sample_creds) |
566 | 172 | 171 | ||
568 | 173 | result = yield kr.get_credentials(APP_NAME) | 172 | result = yield kr.get_credentials("app name") |
569 | 174 | self.assertEqual(result, sample_creds) | 173 | self.assertEqual(result, sample_creds) |
570 | 175 | 174 | ||
571 | 176 | @inlineCallbacks | 175 | @inlineCallbacks |
572 | 177 | 176 | ||
573 | === modified file 'ubuntu_sso/main/__init__.py' | |||
574 | --- ubuntu_sso/main/__init__.py 2012-02-11 01:51:57 +0000 | |||
575 | +++ ubuntu_sso/main/__init__.py 2012-02-18 14:14:18 +0000 | |||
576 | @@ -318,7 +318,7 @@ | |||
577 | 318 | def CredentialsFound(self, app_name, credentials): | 318 | def CredentialsFound(self, app_name, credentials): |
578 | 319 | """Signal thrown when the credentials are found.""" | 319 | """Signal thrown when the credentials are found.""" |
579 | 320 | self.ref_count -= 1 | 320 | self.ref_count -= 1 |
581 | 321 | logger.info('%s: emitting CredentialsFound with app_name "%s".', | 321 | logger.info('%s: emitting CredentialsFound with app_name %r.', |
582 | 322 | self.__class__.__name__, app_name) | 322 | self.__class__.__name__, app_name) |
583 | 323 | self.proxy.CredentialsFound(app_name, credentials) | 323 | self.proxy.CredentialsFound(app_name, credentials) |
584 | 324 | 324 | ||
585 | 325 | 325 | ||
586 | === modified file 'ubuntu_sso/main/tests/test_common.py' | |||
587 | --- ubuntu_sso/main/tests/test_common.py 2012-02-10 17:18:22 +0000 | |||
588 | +++ ubuntu_sso/main/tests/test_common.py 2012-02-18 14:14:18 +0000 | |||
589 | @@ -919,7 +919,8 @@ | |||
590 | 919 | @defer.inlineCallbacks | 919 | @defer.inlineCallbacks |
591 | 920 | def setUp(self): | 920 | def setUp(self): |
592 | 921 | yield super(CredentialsManagementOpsTestCase, self).setUp() | 921 | yield super(CredentialsManagementOpsTestCase, self).setUp() |
594 | 922 | self.args = dict((k, str(v)) for k, v in self.base_args.iteritems()) | 922 | self.args = dict(self.base_args) |
595 | 923 | self.args[WINDOW_ID_KEY] = str(self.args[WINDOW_ID_KEY]) | ||
596 | 923 | self.cred_args = self.base_args.copy() | 924 | self.cred_args = self.base_args.copy() |
597 | 924 | 925 | ||
598 | 925 | def test_register(self): | 926 | def test_register(self): |
599 | @@ -955,12 +956,16 @@ | |||
600 | 955 | class CredentialsManagementSignalsTestCase(CredentialsManagementTestCase): | 956 | class CredentialsManagementSignalsTestCase(CredentialsManagementTestCase): |
601 | 956 | """Tests for the CredentialsManagement DBus signals.""" | 957 | """Tests for the CredentialsManagement DBus signals.""" |
602 | 957 | 958 | ||
603 | 959 | def assert_signal_logged(self, signal, *args): | ||
604 | 960 | """Check that signal info was properly logged.""" | ||
605 | 961 | signal(APP_NAME, *args) | ||
606 | 962 | msgs = [self.obj.__class__.__name__, | ||
607 | 963 | signal.__name__, repr(APP_NAME)] | ||
608 | 964 | self.assertTrue(self.memento.check_info(*msgs)) | ||
609 | 965 | |||
610 | 958 | def test_credentials_found(self): | 966 | def test_credentials_found(self): |
611 | 959 | """The CredentialsFound signal.""" | 967 | """The CredentialsFound signal.""" |
616 | 960 | self.obj.CredentialsFound(APP_NAME, TOKEN) | 968 | self.assert_signal_logged(self.obj.CredentialsFound, TOKEN) |
613 | 961 | msgs = (self.obj.__class__.__name__, | ||
614 | 962 | self.obj.CredentialsFound.__name__, APP_NAME) | ||
615 | 963 | self.assertTrue(self.memento.check_info(*msgs)) | ||
617 | 964 | 969 | ||
618 | 965 | msg = 'credentials must not be logged (found %r in log).' | 970 | msg = 'credentials must not be logged (found %r in log).' |
619 | 966 | for val in TOKEN.itervalues(): | 971 | for val in TOKEN.itervalues(): |
620 | @@ -968,24 +973,15 @@ | |||
621 | 968 | 973 | ||
622 | 969 | def test_credentials_not_found(self): | 974 | def test_credentials_not_found(self): |
623 | 970 | """The CredentialsNotFound signal.""" | 975 | """The CredentialsNotFound signal.""" |
628 | 971 | self.obj.CredentialsNotFound(APP_NAME) | 976 | self.assert_signal_logged(self.obj.CredentialsNotFound) |
625 | 972 | msgs = (self.obj.__class__.__name__, | ||
626 | 973 | self.obj.CredentialsNotFound.__name__, APP_NAME) | ||
627 | 974 | self.assertTrue(self.memento.check_info(*msgs)) | ||
629 | 975 | 977 | ||
630 | 976 | def test_credentials_cleared(self): | 978 | def test_credentials_cleared(self): |
631 | 977 | """The CredentialsCleared signal.""" | 979 | """The CredentialsCleared signal.""" |
636 | 978 | self.obj.CredentialsCleared(APP_NAME) | 980 | self.assert_signal_logged(self.obj.CredentialsCleared) |
633 | 979 | msgs = (self.obj.__class__.__name__, | ||
634 | 980 | self.obj.CredentialsCleared.__name__, APP_NAME) | ||
635 | 981 | self.assertTrue(self.memento.check_info(*msgs)) | ||
637 | 982 | 981 | ||
638 | 983 | def test_credentials_stored(self): | 982 | def test_credentials_stored(self): |
639 | 984 | """The CredentialsStored signal.""" | 983 | """The CredentialsStored signal.""" |
644 | 985 | self.obj.CredentialsStored(APP_NAME) | 984 | self.assert_signal_logged(self.obj.CredentialsStored) |
641 | 986 | msgs = (self.obj.__class__.__name__, | ||
642 | 987 | self.obj.CredentialsStored.__name__, APP_NAME) | ||
643 | 988 | self.assertTrue(self.memento.check_info(*msgs)) | ||
645 | 989 | 985 | ||
646 | 990 | def test_credentials_error(self): | 986 | def test_credentials_error(self): |
647 | 991 | """The CredentialsError signal.""" | 987 | """The CredentialsError signal.""" |
648 | @@ -993,15 +989,12 @@ | |||
649 | 993 | self.obj.CredentialsError(APP_NAME, error) | 989 | self.obj.CredentialsError(APP_NAME, error) |
650 | 994 | msgs = (self.obj.__class__.__name__, | 990 | msgs = (self.obj.__class__.__name__, |
651 | 995 | self.obj.CredentialsError.__name__, | 991 | self.obj.CredentialsError.__name__, |
653 | 996 | APP_NAME, str(error)) | 992 | repr(APP_NAME), repr(error)) |
654 | 997 | self.assertTrue(self.memento.check_error(*msgs)) | 993 | self.assertTrue(self.memento.check_error(*msgs)) |
655 | 998 | 994 | ||
656 | 999 | def test_authorization_denied(self): | 995 | def test_authorization_denied(self): |
657 | 1000 | """The AuthorizationDenied signal.""" | 996 | """The AuthorizationDenied signal.""" |
662 | 1001 | self.obj.AuthorizationDenied(APP_NAME) | 997 | self.assert_signal_logged(self.obj.AuthorizationDenied) |
659 | 1002 | msgs = (self.obj.__class__.__name__, | ||
660 | 1003 | self.obj.AuthorizationDenied.__name__, APP_NAME) | ||
661 | 1004 | self.assertTrue(self.memento.check_info(*msgs)) | ||
663 | 1005 | 998 | ||
664 | 1006 | 999 | ||
665 | 1007 | class UbuntuSSOServiceTestCase(BaseTestCase): | 1000 | class UbuntuSSOServiceTestCase(BaseTestCase): |
666 | 1008 | 1001 | ||
667 | === modified file 'ubuntu_sso/qt/__init__.py' | |||
668 | --- ubuntu_sso/qt/__init__.py 2012-02-09 18:28:40 +0000 | |||
669 | +++ ubuntu_sso/qt/__init__.py 2012-02-18 14:14:18 +0000 | |||
670 | @@ -16,21 +16,11 @@ | |||
671 | 16 | 16 | ||
672 | 17 | """The Qt graphical interface for the Ubuntu Single Sign On Client.""" | 17 | """The Qt graphical interface for the Ubuntu Single Sign On Client.""" |
673 | 18 | 18 | ||
674 | 19 | import gettext | ||
675 | 20 | import collections | 19 | import collections |
676 | 21 | 20 | ||
677 | 22 | 21 | ||
678 | 23 | _ = gettext.gettext | ||
679 | 24 | |||
680 | 25 | ERROR_ALL = '__all__' | 22 | ERROR_ALL = '__all__' |
681 | 26 | ERROR_MESSAGE = 'message' | 23 | ERROR_MESSAGE = 'message' |
682 | 27 | LOCAL_FOLDERS_TITLE = _("Syncing your computer with the cloud") | ||
683 | 28 | LOCAL_FOLDERS_SPACE_HEADER = _("Space (%s)") | ||
684 | 29 | LOCAL_FOLDERS_OFFER_LABEL = _("The folders you have selected to sync " | ||
685 | 30 | "take over your %(quota)s space. You can remove some folders or add " | ||
686 | 31 | "some extra space") | ||
687 | 32 | LOCAL_FOLDERS_CALCULATING = _("Calculating") | ||
688 | 33 | NEXT = _("Next") | ||
689 | 34 | 24 | ||
690 | 35 | 25 | ||
691 | 36 | # Based on the gtk implementation | 26 | # Based on the gtk implementation |
692 | 37 | 27 | ||
693 | === modified file 'ubuntu_sso/qt/current_user_sign_in_page.py' | |||
694 | --- ubuntu_sso/qt/current_user_sign_in_page.py 2012-02-14 14:38:23 +0000 | |||
695 | +++ ubuntu_sso/qt/current_user_sign_in_page.py 2012-02-18 14:14:18 +0000 | |||
696 | @@ -16,7 +16,6 @@ | |||
697 | 16 | 16 | ||
698 | 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.""" |
699 | 18 | 18 | ||
700 | 19 | import gettext | ||
701 | 20 | from functools import partial | 19 | from functools import partial |
702 | 21 | 20 | ||
703 | 22 | from PyQt4 import QtGui, QtCore | 21 | from PyQt4 import QtGui, QtCore |
704 | @@ -27,6 +26,7 @@ | |||
705 | 27 | from ubuntu_sso.qt.gui import SSOWizardPage | 26 | from ubuntu_sso.qt.gui import SSOWizardPage |
706 | 28 | from ubuntu_sso.logger import setup_logging | 27 | from ubuntu_sso.logger import setup_logging |
707 | 29 | from ubuntu_sso.utils.ui import ( | 28 | from ubuntu_sso.utils.ui import ( |
708 | 29 | CANCEL_BUTTON, | ||
709 | 30 | EMAIL_LABEL, | 30 | EMAIL_LABEL, |
710 | 31 | FORGOTTEN_PASSWORD_BUTTON, | 31 | FORGOTTEN_PASSWORD_BUTTON, |
711 | 32 | is_correct_email, | 32 | is_correct_email, |
712 | @@ -38,7 +38,6 @@ | |||
713 | 38 | FORGOTTEN_PASSWORD_LINK_STYLE = '<a href="#">{forgotten_text}</a>' | 38 | FORGOTTEN_PASSWORD_LINK_STYLE = '<a href="#">{forgotten_text}</a>' |
714 | 39 | 39 | ||
715 | 40 | 40 | ||
716 | 41 | _ = gettext.gettext | ||
717 | 42 | logger = setup_logging('ubuntu_sso.current_user_sign_in_page') | 41 | logger = setup_logging('ubuntu_sso.current_user_sign_in_page') |
718 | 43 | 42 | ||
719 | 44 | 43 | ||
720 | @@ -87,8 +86,7 @@ | |||
721 | 87 | 86 | ||
722 | 88 | def initializePage(self): | 87 | def initializePage(self): |
723 | 89 | """Setup UI details.""" | 88 | """Setup UI details.""" |
726 | 90 | self.setButtonText(QtGui.QWizard.CancelButton, | 89 | self.setButtonText(QtGui.QWizard.CancelButton, CANCEL_BUTTON) |
725 | 91 | _("Cancel")) | ||
727 | 92 | # Layout without custom button 1, | 90 | # Layout without custom button 1, |
728 | 93 | # without finish button | 91 | # without finish button |
729 | 94 | self.wizard().setButtonLayout([ | 92 | self.wizard().setButtonLayout([ |
730 | 95 | 93 | ||
731 | === modified file 'ubuntu_sso/qt/gui.py' | |||
732 | --- ubuntu_sso/qt/gui.py 2012-02-14 14:38:23 +0000 | |||
733 | +++ ubuntu_sso/qt/gui.py 2012-02-18 14:14:18 +0000 | |||
734 | @@ -15,7 +15,6 @@ | |||
735 | 15 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
736 | 16 | """Qt implementation of the UI.""" | 16 | """Qt implementation of the UI.""" |
737 | 17 | 17 | ||
738 | 18 | import gettext | ||
739 | 19 | from functools import wraps | 18 | from functools import wraps |
740 | 20 | 19 | ||
741 | 21 | # pylint: disable=F0401,E0611 | 20 | # pylint: disable=F0401,E0611 |
742 | @@ -40,7 +39,6 @@ | |||
743 | 40 | from ubuntu_sso.utils.ui import GENERIC_BACKEND_ERROR | 39 | from ubuntu_sso.utils.ui import GENERIC_BACKEND_ERROR |
744 | 41 | 40 | ||
745 | 42 | 41 | ||
746 | 43 | _ = gettext.gettext | ||
747 | 44 | logger = setup_logging('ubuntu_sso.gui') | 42 | logger = setup_logging('ubuntu_sso.gui') |
748 | 45 | 43 | ||
749 | 46 | 44 | ||
750 | 47 | 45 | ||
751 | === modified file 'ubuntu_sso/qt/network_detection_page.py' | |||
752 | --- ubuntu_sso/qt/network_detection_page.py 2012-02-13 20:27:48 +0000 | |||
753 | +++ ubuntu_sso/qt/network_detection_page.py 2012-02-18 14:14:18 +0000 | |||
754 | @@ -16,17 +16,17 @@ | |||
755 | 16 | 16 | ||
756 | 17 | """Pages from SSO.""" | 17 | """Pages from SSO.""" |
757 | 18 | 18 | ||
758 | 19 | |||
759 | 20 | import gettext | ||
760 | 21 | |||
761 | 22 | from twisted.internet import defer | 19 | from twisted.internet import defer |
762 | 23 | from PyQt4 import QtGui | 20 | from PyQt4 import QtGui |
763 | 24 | 21 | ||
764 | 25 | from ubuntu_sso import networkstate | 22 | from ubuntu_sso import networkstate |
765 | 26 | 23 | ||
766 | 27 | from ubuntu_sso.qt.ui import network_detection_ui | 24 | from ubuntu_sso.qt.ui import network_detection_ui |
769 | 28 | 25 | from ubuntu_sso.utils.ui import ( | |
770 | 29 | _ = gettext.gettext | 26 | CLOSE_AND_SETUP_LATER, |
771 | 27 | NETWORK_DETECTION_TITLE, | ||
772 | 28 | TRY_AGAIN_BUTTON, | ||
773 | 29 | ) | ||
774 | 30 | 30 | ||
775 | 31 | 31 | ||
776 | 32 | class NetworkDetectionPage(QtGui.QWizardPage): | 32 | class NetworkDetectionPage(QtGui.QWizardPage): |
777 | @@ -35,7 +35,7 @@ | |||
778 | 35 | 35 | ||
779 | 36 | def __init__(self, banner_pixmap=None, parent=None): | 36 | def __init__(self, banner_pixmap=None, parent=None): |
780 | 37 | super(NetworkDetectionPage, self).__init__(parent) | 37 | super(NetworkDetectionPage, self).__init__(parent) |
782 | 38 | self.setTitle(_("Network detection")) | 38 | self.setTitle(NETWORK_DETECTION_TITLE) |
783 | 39 | self.ui = network_detection_ui.Ui_Form() | 39 | self.ui = network_detection_ui.Ui_Form() |
784 | 40 | self.ui.setupUi(self) | 40 | self.ui.setupUi(self) |
785 | 41 | if banner_pixmap is not None: | 41 | if banner_pixmap is not None: |
786 | @@ -47,9 +47,9 @@ | |||
787 | 47 | """Set UI details.""" | 47 | """Set UI details.""" |
788 | 48 | self.wizard()._next_id = None | 48 | self.wizard()._next_id = None |
789 | 49 | 49 | ||
791 | 50 | self.setButtonText(QtGui.QWizard.CustomButton1, _("Try again")) | 50 | self.setButtonText(QtGui.QWizard.CustomButton1, TRY_AGAIN_BUTTON) |
792 | 51 | self.setButtonText(QtGui.QWizard.CancelButton, | 51 | self.setButtonText(QtGui.QWizard.CancelButton, |
794 | 52 | _("Close window and set up later")) | 52 | CLOSE_AND_SETUP_LATER) |
795 | 53 | self.wizard().setButtonLayout([ | 53 | self.wizard().setButtonLayout([ |
796 | 54 | QtGui.QWizard.Stretch, | 54 | QtGui.QWizard.Stretch, |
797 | 55 | QtGui.QWizard.CustomButton1, | 55 | QtGui.QWizard.CustomButton1, |
798 | 56 | 56 | ||
799 | === modified file 'ubuntu_sso/qt/setup_account_page.py' | |||
800 | --- ubuntu_sso/qt/setup_account_page.py 2012-02-15 17:33:40 +0000 | |||
801 | +++ ubuntu_sso/qt/setup_account_page.py 2012-02-18 14:14:18 +0000 | |||
802 | @@ -55,7 +55,6 @@ | |||
803 | 55 | is_min_required_password, | 55 | is_min_required_password, |
804 | 56 | is_correct_email, | 56 | is_correct_email, |
805 | 57 | JOIN_HEADER_LABEL, | 57 | JOIN_HEADER_LABEL, |
806 | 58 | NAME, | ||
807 | 59 | NAME_ENTRY, | 58 | NAME_ENTRY, |
808 | 60 | NAME_INVALID, | 59 | NAME_INVALID, |
809 | 61 | PASSWORD, | 60 | PASSWORD, |
810 | @@ -177,7 +176,7 @@ | |||
811 | 177 | self.set_up_button.clicked.connect(self.set_next_validation) | 176 | self.set_up_button.clicked.connect(self.set_next_validation) |
812 | 178 | self.set_up_button.setEnabled(False) | 177 | self.set_up_button.setEnabled(False) |
813 | 179 | 178 | ||
815 | 180 | self.ui.name_label.setText(NAME) | 179 | self.ui.name_label.setText(NAME_ENTRY) |
816 | 181 | self.ui.email_label.setText(EMAIL) | 180 | self.ui.email_label.setText(EMAIL) |
817 | 182 | self.ui.confirm_email_label.setText(RETYPE_EMAIL) | 181 | self.ui.confirm_email_label.setText(RETYPE_EMAIL) |
818 | 183 | self.ui.password_label.setText(PASSWORD) | 182 | self.ui.password_label.setText(PASSWORD) |
819 | @@ -200,7 +199,7 @@ | |||
820 | 200 | #pylint: enable=C0103 | 199 | #pylint: enable=C0103 |
821 | 201 | 200 | ||
822 | 202 | def _set_translated_strings(self): | 201 | def _set_translated_strings(self): |
824 | 203 | """Set the different gettext translated strings.""" | 202 | """Set the strings.""" |
825 | 204 | logger.debug('SetUpAccountPage._set_translated_strings') | 203 | logger.debug('SetUpAccountPage._set_translated_strings') |
826 | 205 | # set the translated string | 204 | # set the translated string |
827 | 206 | self.ui.name_label.setText(NAME_ENTRY) | 205 | self.ui.name_label.setText(NAME_ENTRY) |
828 | 207 | 206 | ||
829 | === modified file 'ubuntu_sso/qt/sign_in_page.py' | |||
830 | --- ubuntu_sso/qt/sign_in_page.py 2012-02-13 20:27:48 +0000 | |||
831 | +++ ubuntu_sso/qt/sign_in_page.py 2012-02-18 14:14:18 +0000 | |||
832 | @@ -16,19 +16,17 @@ | |||
833 | 16 | 16 | ||
834 | 17 | """Page to allow the user to sign in.""" | 17 | """Page to allow the user to sign in.""" |
835 | 18 | 18 | ||
836 | 19 | import gettext | ||
837 | 20 | |||
838 | 21 | from PyQt4 import QtGui, QtCore | 19 | from PyQt4 import QtGui, QtCore |
839 | 22 | 20 | ||
840 | 23 | from ubuntu_sso.qt.gui import SSOWizardPage | 21 | from ubuntu_sso.qt.gui import SSOWizardPage |
841 | 24 | from ubuntu_sso.logger import setup_logging | 22 | from ubuntu_sso.logger import setup_logging |
842 | 25 | from ubuntu_sso.utils.ui import ( | 23 | from ubuntu_sso.utils.ui import ( |
843 | 24 | CLOSE_AND_SETUP_LATER, | ||
844 | 26 | EXISTING_ACCOUNT_CHOICE_BUTTON, | 25 | EXISTING_ACCOUNT_CHOICE_BUTTON, |
845 | 27 | SET_UP_ACCOUNT_CHOICE_BUTTON, | 26 | SET_UP_ACCOUNT_CHOICE_BUTTON, |
846 | 28 | ) | 27 | ) |
847 | 29 | 28 | ||
848 | 30 | 29 | ||
849 | 31 | _ = gettext.gettext | ||
850 | 32 | logger = setup_logging('ubuntu_sso.sing_in_page') | 30 | logger = setup_logging('ubuntu_sso.sing_in_page') |
851 | 33 | 31 | ||
852 | 34 | 32 | ||
853 | @@ -76,7 +74,7 @@ | |||
854 | 76 | 74 | ||
855 | 77 | def initializePage(self): | 75 | def initializePage(self): |
856 | 78 | """Setup UI details.""" | 76 | """Setup UI details.""" |
858 | 79 | self.ui.cancel_button.setText(_("Close window and setup later")) | 77 | self.ui.cancel_button.setText(CLOSE_AND_SETUP_LATER) |
859 | 80 | self.ui.cancel_button.clicked.connect(self.singInCanceled.emit) | 78 | self.ui.cancel_button.clicked.connect(self.singInCanceled.emit) |
860 | 81 | # Layout without custom button 1, | 79 | # Layout without custom button 1, |
861 | 82 | # without finish button | 80 | # without finish button |
862 | 83 | 81 | ||
863 | === modified file 'ubuntu_sso/qt/tests/test_setup_account.py' | |||
864 | --- ubuntu_sso/qt/tests/test_setup_account.py 2012-02-16 14:37:19 +0000 | |||
865 | +++ ubuntu_sso/qt/tests/test_setup_account.py 2012-02-18 14:14:18 +0000 | |||
866 | @@ -232,7 +232,8 @@ | |||
867 | 232 | self.assertFalse(self.ui.captcha_received) | 232 | self.assertFalse(self.ui.captcha_received) |
868 | 233 | 233 | ||
869 | 234 | # labels | 234 | # labels |
871 | 235 | self.assertEqual(self.ui.ui.name_label.text(), setup_account_page.NAME) | 235 | self.assertEqual(self.ui.ui.name_label.text(), |
872 | 236 | setup_account_page.NAME_ENTRY) | ||
873 | 236 | self.assertEqual(self.ui.ui.email_label.text(), | 237 | self.assertEqual(self.ui.ui.email_label.text(), |
874 | 237 | setup_account_page.EMAIL) | 238 | setup_account_page.EMAIL) |
875 | 238 | self.assertEqual(self.ui.ui.confirm_email_label.text(), | 239 | self.assertEqual(self.ui.ui.confirm_email_label.text(), |
876 | 239 | 240 | ||
877 | === modified file 'ubuntu_sso/tests/__init__.py' | |||
878 | --- ubuntu_sso/tests/__init__.py 2012-02-10 17:18:22 +0000 | |||
879 | +++ ubuntu_sso/tests/__init__.py 2012-02-18 14:14:18 +0000 | |||
880 | @@ -26,20 +26,20 @@ | |||
881 | 26 | 26 | ||
882 | 27 | from ubuntu_sso.keyring import get_token_name | 27 | from ubuntu_sso.keyring import get_token_name |
883 | 28 | 28 | ||
885 | 29 | APP_NAME = u'The Super App!' | 29 | APP_NAME = u'I ♥ Ubuntu' |
886 | 30 | CAPTCHA_ID = u'test ñiña' | 30 | CAPTCHA_ID = u'test ñiña' |
887 | 31 | CAPTCHA_PATH = os.path.abspath(os.path.join(os.curdir, 'ubuntu_sso', 'tests', | 31 | CAPTCHA_PATH = os.path.abspath(os.path.join(os.curdir, 'ubuntu_sso', 'tests', |
888 | 32 | 'files', 'captcha.png')) | 32 | 'files', 'captcha.png')) |
889 | 33 | CAPTCHA_SOLUTION = u'william Byrd ñandú' | 33 | CAPTCHA_SOLUTION = u'william Byrd ñandú' |
890 | 34 | EMAIL = u'test@example.com' | 34 | EMAIL = u'test@example.com' |
892 | 35 | EMAIL_TOKEN = u'B2Pgtf' | 35 | EMAIL_TOKEN = u'B2P☺ gtf' |
893 | 36 | GTK_GUI_EXE = 'ubuntu-sso-login-gtk' | 36 | GTK_GUI_EXE = 'ubuntu-sso-login-gtk' |
900 | 37 | HELP_TEXT = """Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sed | 37 | HELP_TEXT = u'☛ Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' \ |
901 | 38 | lorem nibh. Suspendisse gravida nulla non nunc suscipit pulvinar tempus ut | 38 | 'Nam sed lorem nibh. Suspendisse gravida nulla non nunc suscipit pulvinar ' \ |
902 | 39 | augue. Morbi consequat, ligula a elementum pretium, dolor nulla tempus metus, | 39 | 'tempus ut augue. Morbi consequat, ligula a elementum pretium, ' \ |
903 | 40 | sed viverra nisi risus non velit.""" | 40 | 'dolor nulla tempus metus, sed viverra nisi risus non velit.' |
904 | 41 | NAME = u'Juanito Pérez' | 41 | NAME = u'Juanito ☀ Pérez' |
905 | 42 | PASSWORD = u'h3lloWorld' | 42 | PASSWORD = u'h3lloWorld☑ ' |
906 | 43 | PING_URL = u'http://localhost/ping-me/' | 43 | PING_URL = u'http://localhost/ping-me/' |
907 | 44 | POLICY_URL = u'http://localhost/policy/' | 44 | POLICY_URL = u'http://localhost/policy/' |
908 | 45 | RESET_PASSWORD_TOKEN = u'8G5Wtq' | 45 | RESET_PASSWORD_TOKEN = u'8G5Wtq' |
909 | 46 | 46 | ||
910 | === modified file 'ubuntu_sso/utils/runner/glib.py' | |||
911 | --- ubuntu_sso/utils/runner/glib.py 2012-02-10 17:03:56 +0000 | |||
912 | +++ ubuntu_sso/utils/runner/glib.py 2012-02-18 14:14:18 +0000 | |||
913 | @@ -27,7 +27,7 @@ | |||
914 | 27 | logger = setup_logging("ubuntu_sso.utils.runner.glib") | 27 | logger = setup_logging("ubuntu_sso.utils.runner.glib") |
915 | 28 | 28 | ||
916 | 29 | 29 | ||
918 | 30 | NO_SUCH_FILE_OR_DIR = '(No such file or directory)' | 30 | NO_SUCH_FILE_OR_DIR = 'No such file or directory' |
919 | 31 | 31 | ||
920 | 32 | 32 | ||
921 | 33 | def spawn_program(args, reply_handler, error_handler): | 33 | def spawn_program(args, reply_handler, error_handler): |
922 | @@ -66,8 +66,17 @@ | |||
923 | 66 | GLib.SpawnFlags.STDOUT_TO_DEV_NULL | \ | 66 | GLib.SpawnFlags.STDOUT_TO_DEV_NULL | \ |
924 | 67 | GLib.SpawnFlags.STDERR_TO_DEV_NULL | 67 | GLib.SpawnFlags.STDERR_TO_DEV_NULL |
925 | 68 | pid = None | 68 | pid = None |
926 | 69 | |||
927 | 70 | bytes_args = [] | ||
928 | 71 | for arg in args: | ||
929 | 72 | if isinstance(arg, unicode): | ||
930 | 73 | arg = arg.encode('utf-8') | ||
931 | 74 | if not isinstance(arg, basestring): | ||
932 | 75 | arg = str(arg) | ||
933 | 76 | bytes_args.append(arg) | ||
934 | 77 | |||
935 | 69 | try: | 78 | try: |
937 | 70 | pid, _, _, _ = GLib.spawn_async(argv=args, flags=flags) | 79 | pid, _, _, _ = GLib.spawn_async(argv=bytes_args, flags=flags) |
938 | 71 | except GLib.GError, e: | 80 | except GLib.GError, e: |
939 | 72 | handle_error(e) | 81 | handle_error(e) |
940 | 73 | else: | 82 | else: |
941 | 74 | 83 | ||
942 | === added file 'ubuntu_sso/utils/runner/tests/test_glib.py' | |||
943 | --- ubuntu_sso/utils/runner/tests/test_glib.py 1970-01-01 00:00:00 +0000 | |||
944 | +++ ubuntu_sso/utils/runner/tests/test_glib.py 2012-02-18 14:14:18 +0000 | |||
945 | @@ -0,0 +1,132 @@ | |||
946 | 1 | # -*- coding: utf-8 -*- | ||
947 | 2 | # | ||
948 | 3 | # Copyright 2012 Canonical Ltd. | ||
949 | 4 | # | ||
950 | 5 | # This program is free software: you can redistribute it and/or modify it | ||
951 | 6 | # under the terms of the GNU General Public License version 3, as published | ||
952 | 7 | # by the Free Software Foundation. | ||
953 | 8 | # | ||
954 | 9 | # This program is distributed in the hope that it will be useful, but | ||
955 | 10 | # WITHOUT ANY WARRANTY; without even the implied warranties of | ||
956 | 11 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
957 | 12 | # PURPOSE. See the GNU General Public License for more details. | ||
958 | 13 | # | ||
959 | 14 | # You should have received a copy of the GNU General Public License along | ||
960 | 15 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
961 | 16 | |||
962 | 17 | """Tests for the glib runner helper module.""" | ||
963 | 18 | |||
964 | 19 | import subprocess | ||
965 | 20 | |||
966 | 21 | # pylint: disable=E0611 | ||
967 | 22 | from gi.repository import GLib | ||
968 | 23 | # pylint: enable=E0611 | ||
969 | 24 | from twisted.internet import defer | ||
970 | 25 | |||
971 | 26 | from ubuntu_sso.utils import runner | ||
972 | 27 | from ubuntu_sso.utils.runner import glib | ||
973 | 28 | from ubuntu_sso.utils.runner.tests.test_runner import SpawnProgramTestCase | ||
974 | 29 | |||
975 | 30 | |||
976 | 31 | class FakedSignal(object): | ||
977 | 32 | """Fake a glib signal.""" | ||
978 | 33 | |||
979 | 34 | def __init__(self, name): | ||
980 | 35 | self.name = name | ||
981 | 36 | self._handlers = [] | ||
982 | 37 | |||
983 | 38 | def connect(self, handler): | ||
984 | 39 | """Connect 'handler' with this signal.""" | ||
985 | 40 | self._handlers.append(handler) | ||
986 | 41 | |||
987 | 42 | def emit(self, *args, **kwargs): | ||
988 | 43 | """Emit this signal.""" | ||
989 | 44 | for handler in self._handlers: | ||
990 | 45 | handler(*args, **kwargs) | ||
991 | 46 | |||
992 | 47 | |||
993 | 48 | class FakedProcess(object): | ||
994 | 49 | """Fake a glib Process.""" | ||
995 | 50 | |||
996 | 51 | _argv = _flags = None | ||
997 | 52 | _pid = 123456 | ||
998 | 53 | _pids = [] | ||
999 | 54 | _status_code = 0 | ||
1000 | 55 | |||
1001 | 56 | SpawnFlags = GLib.SpawnFlags | ||
1002 | 57 | GError = GLib.GError | ||
1003 | 58 | |||
1004 | 59 | def __init__(self): | ||
1005 | 60 | self.pid = lambda: self._pid | ||
1006 | 61 | self.started = FakedSignal('started') | ||
1007 | 62 | self.finished = FakedSignal('finished') | ||
1008 | 63 | self.error = FakedSignal('error') | ||
1009 | 64 | |||
1010 | 65 | def spawn_async(self, argv, flags): | ||
1011 | 66 | """Spwan a process.""" | ||
1012 | 67 | if 'None' in argv: | ||
1013 | 68 | exc = GLib.GError() | ||
1014 | 69 | exc.message = str('Can not handle None') | ||
1015 | 70 | exc.code = 24 | ||
1016 | 71 | raise exc | ||
1017 | 72 | |||
1018 | 73 | self._argv = argv | ||
1019 | 74 | self._flags = flags | ||
1020 | 75 | |||
1021 | 76 | try: | ||
1022 | 77 | subprocess.call(argv) | ||
1023 | 78 | except Exception, e: | ||
1024 | 79 | exc = GLib.GError() | ||
1025 | 80 | exc.message = str(e) | ||
1026 | 81 | exc.code = 42 | ||
1027 | 82 | raise exc | ||
1028 | 83 | |||
1029 | 84 | self._pids.append(self._pid) | ||
1030 | 85 | return (self._pid, None, None, None) | ||
1031 | 86 | |||
1032 | 87 | def child_watch_add(self, pid, child_watch): | ||
1033 | 88 | """Addd a child watch.""" | ||
1034 | 89 | if pid in self._pids: | ||
1035 | 90 | child_watch(pid, self._status_code) | ||
1036 | 91 | |||
1037 | 92 | def spawn_close_pid(self, pid): | ||
1038 | 93 | """Close the 'pid'.""" | ||
1039 | 94 | self._pids.remove(pid) | ||
1040 | 95 | |||
1041 | 96 | |||
1042 | 97 | class GLibSpawnProgramTestCase(SpawnProgramTestCase): | ||
1043 | 98 | """The test suite for the spawn_program method (using GLib).""" | ||
1044 | 99 | |||
1045 | 100 | use_reactor = False | ||
1046 | 101 | |||
1047 | 102 | @defer.inlineCallbacks | ||
1048 | 103 | def setUp(self): | ||
1049 | 104 | yield super(GLibSpawnProgramTestCase, self).setUp() | ||
1050 | 105 | # Since we can't mix plan glib runner and the gireactor, we patch | ||
1051 | 106 | # GLib.spawn_async and fake the conditions so the glib runner is chosen | ||
1052 | 107 | self.process = FakedProcess() | ||
1053 | 108 | self.patch(glib, 'GLib', self.process) | ||
1054 | 109 | self.patch(runner, 'is_twisted_reactor_installed', lambda: False) | ||
1055 | 110 | self.patch(runner, 'is_qt4_main_loop_installed', lambda: False) | ||
1056 | 111 | |||
1057 | 112 | # Access to a protected member _flags, _argv of a client class | ||
1058 | 113 | # pylint: disable=W0212 | ||
1059 | 114 | |||
1060 | 115 | @defer.inlineCallbacks | ||
1061 | 116 | def test_flags_are_correct(self): | ||
1062 | 117 | """The flags are the correct ones.""" | ||
1063 | 118 | yield self.spawn_fn(self.args) | ||
1064 | 119 | |||
1065 | 120 | flags = GLib.SpawnFlags.DO_NOT_REAP_CHILD | \ | ||
1066 | 121 | GLib.SpawnFlags.SEARCH_PATH | \ | ||
1067 | 122 | GLib.SpawnFlags.STDOUT_TO_DEV_NULL | \ | ||
1068 | 123 | GLib.SpawnFlags.STDERR_TO_DEV_NULL | ||
1069 | 124 | self.assertEqual(self.process._flags, flags) | ||
1070 | 125 | |||
1071 | 126 | @defer.inlineCallbacks | ||
1072 | 127 | def test_argv_is_bytes(self): | ||
1073 | 128 | """The argv parameter is converted to bytes.""" | ||
1074 | 129 | yield self.spawn_fn(self.args) | ||
1075 | 130 | |||
1076 | 131 | bytes_args = [a.encode('utf-8') for a in self.args] | ||
1077 | 132 | self.assertEqual(self.process._argv, bytes_args) | ||
1078 | 0 | 133 | ||
1079 | === modified file 'ubuntu_sso/utils/runner/tests/test_qt.py' | |||
1080 | --- ubuntu_sso/utils/runner/tests/test_qt.py 2012-02-10 15:44:28 +0000 | |||
1081 | +++ ubuntu_sso/utils/runner/tests/test_qt.py 2012-02-18 14:14:18 +0000 | |||
1082 | @@ -64,8 +64,16 @@ | |||
1083 | 64 | self.started.emit() | 64 | self.started.emit() |
1084 | 65 | 65 | ||
1085 | 66 | args = (program,) + tuple(arguments) | 66 | args = (program,) + tuple(arguments) |
1086 | 67 | |||
1087 | 68 | # subprocess expects bytes | ||
1088 | 69 | bytes_args = [] | ||
1089 | 70 | for arg in args: | ||
1090 | 71 | if isinstance(arg, unicode): | ||
1091 | 72 | arg = arg.encode('utf-8') | ||
1092 | 73 | bytes_args.append(arg) | ||
1093 | 74 | |||
1094 | 67 | try: | 75 | try: |
1096 | 68 | subprocess.call(args) | 76 | subprocess.call(bytes_args) |
1097 | 69 | except OSError, e: | 77 | except OSError, e: |
1098 | 70 | if e.errno == 2: | 78 | if e.errno == 2: |
1099 | 71 | self.error.emit(self.FailedToStart) | 79 | self.error.emit(self.FailedToStart) |
1100 | 72 | 80 | ||
1101 | === modified file 'ubuntu_sso/utils/runner/tests/test_runner.py' | |||
1102 | --- ubuntu_sso/utils/runner/tests/test_runner.py 2012-02-08 02:13:03 +0000 | |||
1103 | +++ ubuntu_sso/utils/runner/tests/test_runner.py 2012-02-18 14:14:18 +0000 | |||
1104 | @@ -24,21 +24,23 @@ | |||
1105 | 24 | from ubuntu_sso.utils import runner | 24 | from ubuntu_sso.utils import runner |
1106 | 25 | 25 | ||
1107 | 26 | 26 | ||
1109 | 27 | TEST_ME_DIR = 'test-me' | 27 | TEST_ME_DIR = u'test-me-more-♥' |
1110 | 28 | TEST_ME_DIR_BYTES = TEST_ME_DIR.encode('utf-8') | ||
1111 | 28 | 29 | ||
1112 | 29 | 30 | ||
1113 | 30 | class SpawnProgramTestCase(TestCase): | 31 | class SpawnProgramTestCase(TestCase): |
1114 | 31 | """The test suite for the spawn_program method.""" | 32 | """The test suite for the spawn_program method.""" |
1115 | 32 | 33 | ||
1116 | 33 | timeout = 3 | 34 | timeout = 3 |
1118 | 34 | args = ('python', '-c', 'import os; os.system("mkdir %s")' % TEST_ME_DIR) | 35 | args = (u'python', u'-c', |
1119 | 36 | u'import os; os.system("mkdir %s")' % TEST_ME_DIR) | ||
1120 | 35 | 37 | ||
1121 | 36 | @defer.inlineCallbacks | 38 | @defer.inlineCallbacks |
1122 | 37 | def setUp(self): | 39 | def setUp(self): |
1123 | 38 | yield super(SpawnProgramTestCase, self).setUp() | 40 | yield super(SpawnProgramTestCase, self).setUp() |
1127 | 39 | assert not os.path.exists(TEST_ME_DIR) | 41 | assert not os.path.exists(TEST_ME_DIR_BYTES) |
1128 | 40 | self.addCleanup(lambda: os.path.exists(TEST_ME_DIR) and | 42 | self.addCleanup(lambda: os.path.exists(TEST_ME_DIR_BYTES) and |
1129 | 41 | os.rmdir(TEST_ME_DIR)) | 43 | os.rmdir(TEST_ME_DIR_BYTES)) |
1130 | 42 | 44 | ||
1131 | 43 | def spawn_fn(self, args): | 45 | def spawn_fn(self, args): |
1132 | 44 | """The target function to test.""" | 46 | """The target function to test.""" |
1133 | @@ -46,8 +48,8 @@ | |||
1134 | 46 | 48 | ||
1135 | 47 | def assert_command_was_run(self): | 49 | def assert_command_was_run(self): |
1136 | 48 | """The spawnned commnad was correctly run.""" | 50 | """The spawnned commnad was correctly run.""" |
1139 | 49 | self.assertTrue(os.path.exists(TEST_ME_DIR)) | 51 | self.assertTrue(os.path.exists(TEST_ME_DIR_BYTES)) |
1140 | 50 | self.assertTrue(os.path.isdir(TEST_ME_DIR)) | 52 | self.assertTrue(os.path.isdir(TEST_ME_DIR_BYTES)) |
1141 | 51 | 53 | ||
1142 | 52 | @defer.inlineCallbacks | 54 | @defer.inlineCallbacks |
1143 | 53 | def test_program_is_spawned(self): | 55 | def test_program_is_spawned(self): |
1144 | 54 | 56 | ||
1145 | === modified file 'ubuntu_sso/utils/runner/tx.py' | |||
1146 | --- ubuntu_sso/utils/runner/tx.py 2012-02-08 18:29:39 +0000 | |||
1147 | +++ ubuntu_sso/utils/runner/tx.py 2012-02-18 14:14:18 +0000 | |||
1148 | @@ -68,6 +68,14 @@ | |||
1149 | 68 | program = args[0] | 68 | program = args[0] |
1150 | 69 | argv = args[1:] | 69 | argv = args[1:] |
1151 | 70 | 70 | ||
1152 | 71 | bytes_args = [] | ||
1153 | 72 | for arg in argv: | ||
1154 | 73 | if isinstance(arg, unicode): | ||
1155 | 74 | arg = arg.encode('utf-8') | ||
1156 | 75 | if not isinstance(arg, basestring): | ||
1157 | 76 | arg = str(arg) | ||
1158 | 77 | bytes_args.append(arg) | ||
1159 | 78 | |||
1160 | 71 | if program and not os.access(program, os.X_OK): | 79 | if program and not os.access(program, os.X_OK): |
1161 | 72 | # handle searching the executable in the PATH, since | 80 | # handle searching the executable in the PATH, since |
1162 | 73 | # twisted will not solve that for us :-/ | 81 | # twisted will not solve that for us :-/ |
1163 | @@ -81,7 +89,7 @@ | |||
1164 | 81 | break | 89 | break |
1165 | 82 | 90 | ||
1166 | 83 | try: | 91 | try: |
1168 | 84 | d = utils.getProcessOutputAndValue(program, argv, env=os.environ) | 92 | d = utils.getProcessOutputAndValue(program, bytes_args, env=os.environ) |
1169 | 85 | except OSError, e: | 93 | except OSError, e: |
1170 | 86 | error_handler(msg=e, failed_to_start=True) | 94 | error_handler(msg=e, failed_to_start=True) |
1171 | 87 | except Exception, e: | 95 | except Exception, e: |
1172 | 88 | 96 | ||
1173 | === modified file 'ubuntu_sso/utils/ui.py' | |||
1174 | --- ubuntu_sso/utils/ui.py 2012-02-13 20:27:48 +0000 | |||
1175 | +++ ubuntu_sso/utils/ui.py 2012-02-18 14:14:18 +0000 | |||
1176 | @@ -21,11 +21,12 @@ | |||
1177 | 21 | 21 | ||
1178 | 22 | from ubuntu_sso.logger import setup_logging | 22 | from ubuntu_sso.logger import setup_logging |
1179 | 23 | 23 | ||
1180 | 24 | |||
1181 | 25 | gettext.install('ubuntu-sso-client', unicode=True) | ||
1182 | 24 | logger = setup_logging('ubuntu_sso.utils.ui') | 26 | logger = setup_logging('ubuntu_sso.utils.ui') |
1183 | 25 | 27 | ||
1184 | 26 | 28 | ||
1187 | 27 | gettext.textdomain('ubuntu-sso-client') | 29 | # Undefined variable '_', pylint: disable=E0602 |
1186 | 28 | _ = gettext.gettext | ||
1188 | 29 | 30 | ||
1189 | 30 | # all the text that is used in the gui | 31 | # all the text that is used in the gui |
1190 | 31 | AGREE_TO_PRIVACY_POLICY = _('By signing up to {app_name} you agree to ' | 32 | AGREE_TO_PRIVACY_POLICY = _('By signing up to {app_name} you agree to ' |
1191 | @@ -33,11 +34,13 @@ | |||
1192 | 33 | AGREE_TO_TERMS = _('By signing up to {app_name} you agree to ' | 34 | AGREE_TO_TERMS = _('By signing up to {app_name} you agree to ' |
1193 | 34 | 'our {terms_and_conditions}') | 35 | 'our {terms_and_conditions}') |
1194 | 35 | AGREE_TO_TERMS_AND_PRIVACY_POLICY = AGREE_TO_TERMS + _(' and {privacy_policy}') | 36 | AGREE_TO_TERMS_AND_PRIVACY_POLICY = AGREE_TO_TERMS + _(' and {privacy_policy}') |
1195 | 37 | CANCEL_BUTTON = _('Cancel') | ||
1196 | 36 | CAPTCHA_SOLUTION_ENTRY = _('Type the characters above') | 38 | CAPTCHA_SOLUTION_ENTRY = _('Type the characters above') |
1197 | 37 | CAPTCHA_LOAD_ERROR = _('There was a problem getting the captcha, ' | 39 | CAPTCHA_LOAD_ERROR = _('There was a problem getting the captcha, ' |
1198 | 38 | 'reloading...') | 40 | 'reloading...') |
1199 | 39 | CAPTCHA_RELOAD_TOOLTIP = _('Reload') | 41 | CAPTCHA_RELOAD_TOOLTIP = _('Reload') |
1200 | 40 | CAPTCHA_REQUIRED_ERROR = _('The captcha is a required field') | 42 | CAPTCHA_REQUIRED_ERROR = _('The captcha is a required field') |
1201 | 43 | CLOSE_AND_SETUP_LATER = _('Close window and setup later') | ||
1202 | 41 | CONGRATULATIONS = _("Congratulations, {app_name} is installed!") | 44 | CONGRATULATIONS = _("Congratulations, {app_name} is installed!") |
1203 | 42 | PROXY_CREDS_DIALOG_TITLE = _('Add proxy settings') | 45 | PROXY_CREDS_DIALOG_TITLE = _('Add proxy settings') |
1204 | 43 | PROXY_CREDS_HEADER = _('You are connecting through a proxy.') | 46 | PROXY_CREDS_HEADER = _('You are connecting through a proxy.') |
1205 | @@ -76,10 +79,10 @@ | |||
1206 | 76 | LOGIN_HEADER_LABEL = _('Connect to %(app_name)s') | 79 | LOGIN_HEADER_LABEL = _('Connect to %(app_name)s') |
1207 | 77 | LOGIN_PASSWORD_ENTRY = _('Password') | 80 | LOGIN_PASSWORD_ENTRY = _('Password') |
1208 | 78 | LOGIN_PASSWORD_LABEL = LOGIN_PASSWORD_ENTRY | 81 | LOGIN_PASSWORD_LABEL = LOGIN_PASSWORD_ENTRY |
1209 | 79 | NAME = _("Name") | ||
1210 | 80 | NAME_ENTRY = _('Name') | 82 | NAME_ENTRY = _('Name') |
1211 | 81 | NAME_INVALID = _('The name must not be empty.') | 83 | NAME_INVALID = _('The name must not be empty.') |
1212 | 82 | NEXT = _('Next') | 84 | NEXT = _('Next') |
1213 | 85 | NETWORK_DETECTION_TITLE = _('Network detection') | ||
1214 | 83 | ONE_MOMENT_PLEASE = _('One moment please...') | 86 | ONE_MOMENT_PLEASE = _('One moment please...') |
1215 | 84 | PASSWORD = _("Create a password") | 87 | PASSWORD = _("Create a password") |
1216 | 85 | PASSWORD_CHANGED = _('Your password was successfully changed.') | 88 | PASSWORD_CHANGED = _('Your password was successfully changed.') |
1217 | @@ -140,6 +143,8 @@ | |||
1218 | 140 | YES_TO_TC = _('I agree with the %(app_name)s terms and conditions') | 143 | YES_TO_TC = _('I agree with the %(app_name)s terms and conditions') |
1219 | 141 | YES_TO_UPDATES = _('Yes! Email me %(app_name)s tips and updates.') | 144 | YES_TO_UPDATES = _('Yes! Email me %(app_name)s tips and updates.') |
1220 | 142 | 145 | ||
1221 | 146 | # pylint: enable=E0602 | ||
1222 | 147 | |||
1223 | 143 | 148 | ||
1224 | 144 | def get_password_strength(password): | 149 | def get_password_strength(password): |
1225 | 145 | """Return the strength of the password. | 150 | """Return the strength of the password. |
Looks good, great that the tests use unicode characters, nice incremental refactorings.