Merge lp:~nataliabidart/ubuntu-sso-client/fallback-to-gtk into lp:ubuntu-sso-client

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 893
Merged at revision: 889
Proposed branch: lp:~nataliabidart/ubuntu-sso-client/fallback-to-gtk
Merge into: lp:ubuntu-sso-client
Diff against target: 84 lines (+42/-6)
2 files modified
ubuntu_sso/credentials.py (+7/-0)
ubuntu_sso/tests/test_credentials.py (+35/-6)
To merge this branch: bzr merge lp:~nataliabidart/ubuntu-sso-client/fallback-to-gtk
Reviewer Review Type Date Requested Status
dobey (community) Approve
Roberto Alsina (community) Approve
Review via email: mp+94601@code.launchpad.net

Commit message

- Fallback to the GTK+ UI when the specified ui_executable does not exist
  (LP: #939821).

To post a comment you must log in.
890. By Natalia Bidart

Merged trunk in.

891. By Natalia Bidart

Fixed lint issue.

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

+1

review: Approve
892. By Natalia Bidart

Typo fixed.

Revision history for this message
dobey (dobey) wrote :

9 + logger.debug('Fallbacking to the GTK+ UI since the given %r '

"Fallbacking" isn't a word, but "Falling back" is probably what you mean here?

58 + """The executable fallbacks to the GTK+ UI if given does not exist."""

Likewise, instead of "fallbacks" (which would be plural of fallback), you want to use "falls back to" here.

review: Needs Fixing
893. By Natalia Bidart

Correct english grammar.

Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/credentials.py'
2--- ubuntu_sso/credentials.py 2012-02-17 18:43:17 +0000
3+++ ubuntu_sso/credentials.py 2012-02-24 19:51:20 +0000
4@@ -142,6 +142,13 @@
5 def _show_ui(self, login_only):
6 """Shows the UI, connect outcome signals."""
7 ui_exe_path = os.path.join(get_bin_dir(), self.ui_executable)
8+ if not os.path.exists(ui_exe_path):
9+ logger.debug('Falling back to the GTK+ UI since the given %r '
10+ 'does not exist', ui_exe_path)
11+ ui_exe_path = os.path.join(get_bin_dir(), UI_EXECUTABLE_GTK)
12+
13+ assert os.path.exists(ui_exe_path)
14+
15 args = [ui_exe_path]
16 for arg in ('app_name', 'help_text', 'ping_url', 'policy_url',
17 'tc_url', 'window_id'):
18
19=== modified file 'ubuntu_sso/tests/test_credentials.py'
20--- ubuntu_sso/tests/test_credentials.py 2012-02-11 19:25:01 +0000
21+++ ubuntu_sso/tests/test_credentials.py 2012-02-24 19:51:20 +0000
22@@ -272,8 +272,10 @@
23 yield super(RegisterTestCase, self).setUp()
24 self.deferred = defer.Deferred()
25 self.patch_inner(self.fake_inner)
26+ self.exe_path = os.path.join(utils.get_bin_dir(),
27+ KWARGS[UI_EXECUTABLE_KEY])
28 self.inner_args = [
29- os.path.join(utils.get_bin_dir(), KWARGS[UI_EXECUTABLE_KEY]),
30+ self.exe_path,
31 '--app_name', APP_NAME,
32 '--help_text', HELP_TEXT,
33 '--ping_url', PING_URL,
34@@ -332,11 +334,35 @@
35 lambda kr, app: defer.succeed(None))
36 self._next_inner_result = credentials.USER_SUCCESS
37
38- result = yield self.method_call(**self.kwargs)
39- self.assertEqual(result, TOKEN)
40-
41- # the ui was opened and proper params were passed
42- args = yield self.deferred
43+ # patch os.path.exists so it also returns True when queried for the
44+ # faked exe_path
45+ really_exists = os.path.exists
46+ self.patch(credentials.os.path, 'exists',
47+ lambda path: path == self.exe_path or really_exists(path))
48+
49+ result = yield self.method_call(**self.kwargs)
50+ self.assertEqual(result, TOKEN)
51+
52+ # the ui was opened and proper params were passed
53+ args = yield self.deferred
54+ self.assertEqual(self.inner_args, args)
55+
56+ @defer.inlineCallbacks
57+ def test_ui_executable_falls_back_to_gtk(self):
58+ """The executable falls back to the GTK+ UI if given does not exist."""
59+ self.patch(credentials.Keyring, 'get_credentials',
60+ lambda kr, app: defer.succeed(None))
61+ self._next_inner_result = credentials.USER_SUCCESS
62+
63+ assert not os.path.exists(self.exe_path)
64+
65+ result = yield self.method_call(**self.kwargs)
66+ self.assertEqual(result, TOKEN)
67+
68+ # the ui was opened and proper params were passed
69+ args = yield self.deferred
70+ self.inner_args[0] = os.path.join(utils.get_bin_dir(),
71+ credentials.UI_EXECUTABLE_GTK)
72 self.assertEqual(self.inner_args, args)
73
74 @defer.inlineCallbacks
75@@ -436,6 +462,9 @@
76 """Make the inner call fail."""
77 raise SampleMiscException(kwargs)
78
79+ def test_ui_executable_falls_back_to_gtk(self):
80+ """This check does not apply for this test case."""
81+
82 def test_without_existent_token_and_return_code_cancel(self, exc=None):
83 """The operation returns UserNotValidatedError."""
84 exc = credentials.UserNotValidatedError

Subscribers

People subscribed via source and target branches