Merge lp:~jml/bzr/verbose-lp-login-bug-217031 into lp:~bzr/bzr/trunk-old

Proposed by Jonathan Lange
Status: Merged
Approved by: Jonathan Lange
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~jml/bzr/verbose-lp-login-bug-217031
Merge into: lp:~bzr/bzr/trunk-old
Diff against target: 133 lines
To merge this branch: bzr merge lp:~jml/bzr/verbose-lp-login-bug-217031
Reviewer Review Type Date Requested Status
Vincent Ladeuil Approve
Review via email: mp+8172@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jonathan Lange (jml) wrote :

This makes lp-login respect the verbose option. It also adds a bunch of blackbox tests for lp-login.

Revision history for this message
Vincent Ladeuil (vila) wrote :

Nice.

Too bad we don't have a lp test server in our suite :-P

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2009-07-02 04:49:28 +0000
+++ NEWS 2009-07-03 09:35:08 +0000
@@ -105,6 +105,9 @@
105* Progress bars no longer show the network transport scheme or direction.105* Progress bars no longer show the network transport scheme or direction.
106 (Martin Pool)106 (Martin Pool)
107107
108* launchpad-login now respects the 'verbose' option.
109 (Jonathan Lange, #217031)
110
108111
109Internals112Internals
110*********113*********
111114
=== modified file 'bzrlib/plugins/launchpad/__init__.py'
--- bzrlib/plugins/launchpad/__init__.py 2009-06-19 15:10:17 +0000
+++ bzrlib/plugins/launchpad/__init__.py 2009-07-03 09:35:08 +0000
@@ -220,11 +220,12 @@
220 aliases = ['lp-login']220 aliases = ['lp-login']
221 takes_args = ['name?']221 takes_args = ['name?']
222 takes_options = [222 takes_options = [
223 'verbose',
223 Option('no-check',224 Option('no-check',
224 "Don't check that the user name is valid."),225 "Don't check that the user name is valid."),
225 ]226 ]
226227
227 def run(self, name=None, no_check=False):228 def run(self, name=None, no_check=False, verbose=False):
228 from bzrlib.plugins.launchpad import account229 from bzrlib.plugins.launchpad import account
229 check_account = not no_check230 check_account = not no_check
230231
@@ -233,6 +234,9 @@
233 if username:234 if username:
234 if check_account:235 if check_account:
235 account.check_lp_login(username)236 account.check_lp_login(username)
237 if verbose:
238 self.outf.write(
239 "Launchpad user ID exists and has SSH keys.\n")
236 self.outf.write(username + '\n')240 self.outf.write(username + '\n')
237 else:241 else:
238 self.outf.write('No Launchpad user ID configured.\n')242 self.outf.write('No Launchpad user ID configured.\n')
@@ -241,7 +245,12 @@
241 name = name.lower()245 name = name.lower()
242 if check_account:246 if check_account:
243 account.check_lp_login(name)247 account.check_lp_login(name)
248 if verbose:
249 self.outf.write(
250 "Launchpad user ID exists and has SSH keys.\n")
244 account.set_lp_login(name)251 account.set_lp_login(name)
252 if verbose:
253 self.outf.write("Launchpad user ID set to '%s'.\n" % (name,))
245254
246register_command(cmd_launchpad_login)255register_command(cmd_launchpad_login)
247256
@@ -259,6 +268,7 @@
259 from bzrlib.plugins.launchpad import (268 from bzrlib.plugins.launchpad import (
260 test_account,269 test_account,
261 test_lp_directory,270 test_lp_directory,
271 test_lp_login,
262 test_lp_open,272 test_lp_open,
263 test_lp_service,273 test_lp_service,
264 test_register,274 test_register,
@@ -270,6 +280,7 @@
270 test_account,280 test_account,
271 test_register,281 test_register,
272 test_lp_directory,282 test_lp_directory,
283 test_lp_login,
273 test_lp_open,284 test_lp_open,
274 test_lp_service,285 test_lp_service,
275 ]:286 ]:
276287
=== added file 'bzrlib/plugins/launchpad/test_lp_login.py'
--- bzrlib/plugins/launchpad/test_lp_login.py 1970-01-01 00:00:00 +0000
+++ bzrlib/plugins/launchpad/test_lp_login.py 2009-07-03 09:35:08 +0000
@@ -0,0 +1,58 @@
1# Copyright (C) 2009 Canonical Ltd
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17"""Tests for the launchpad-login command."""
18
19from bzrlib.plugins.launchpad import account
20from bzrlib.tests import TestCaseWithTransport
21
22
23class TestLaunchpadLogin(TestCaseWithTransport):
24 """Tests for launchpad-login."""
25
26 def test_login_without_name_when_not_logged_in(self):
27 # lp-login without a 'name' parameter returns the user ID of the
28 # logged in user. If no one is logged in, we tell the user as much.
29 out, err = self.run_bzr(['launchpad-login', '--no-check'], retcode=1)
30 self.assertEqual('No Launchpad user ID configured.\n', out)
31 self.assertEqual('', err)
32
33 def test_login_with_name_sets_login(self):
34 # lp-login with a 'name' parameter sets the Launchpad login.
35 self.run_bzr(['launchpad-login', '--no-check', 'foo'])
36 self.assertEqual('foo', account.get_lp_login())
37
38 def test_login_without_name_when_logged_in(self):
39 # lp-login without a 'name' parameter returns the user ID of the
40 # logged in user.
41 account.set_lp_login('foo')
42 out, err = self.run_bzr(['launchpad-login', '--no-check'])
43 self.assertEqual('foo\n', out)
44 self.assertEqual('', err)
45
46 def test_login_with_name_no_output_by_default(self):
47 # lp-login with a 'name' parameter produces no output by default.
48 out, err = self.run_bzr(['launchpad-login', '--no-check', 'foo'])
49 self.assertEqual('', out)
50 self.assertEqual('', err)
51
52 def test_login_with_name_verbose(self):
53 # lp-login with a 'name' parameter and a verbose flag produces some
54 # information about what Bazaar just did.
55 out, err = self.run_bzr(
56 ['launchpad-login', '-v', '--no-check', 'foo'])
57 self.assertEqual("Launchpad user ID set to 'foo'.\n", out)
58 self.assertEqual('', err)