Rev 4506: (jml) Make lp-login respect the verbose flag, fixing bug 217031. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Jul 3 11:21:38 BST 2009


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4506 [merge]
revision-id: pqm at pqm.ubuntu.com-20090703102135-edbqugohr9mu020k
parent: pqm at pqm.ubuntu.com-20090702231053-955txia3151h0z2o
parent: jml at canonical.com-20090703091656-fajg1g8645arxbjm
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2009-07-03 11:21:35 +0100
message:
  (jml) Make lp-login respect the verbose flag, fixing bug 217031.
added:
  bzrlib/plugins/launchpad/test_lp_login.py test_lp_login.py-20090703084233-aggmid0z3n57oi42-1
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/plugins/launchpad/__init__.py __init__.py-20060315182712-2d5feebd2a1032dc
=== modified file 'NEWS'
--- a/NEWS	2009-07-02 04:49:28 +0000
+++ b/NEWS	2009-07-03 09:16:56 +0000
@@ -105,6 +105,9 @@
 * Progress bars no longer show the network transport scheme or direction.
   (Martin Pool)
 
+* launchpad-login now respects the 'verbose' option.
+  (Jonathan Lange, #217031)
+
 
 Internals
 *********

=== modified file 'bzrlib/plugins/launchpad/__init__.py'
--- a/bzrlib/plugins/launchpad/__init__.py	2009-06-19 15:10:17 +0000
+++ b/bzrlib/plugins/launchpad/__init__.py	2009-07-03 08:57:53 +0000
@@ -220,11 +220,12 @@
     aliases = ['lp-login']
     takes_args = ['name?']
     takes_options = [
+        'verbose',
         Option('no-check',
                "Don't check that the user name is valid."),
         ]
 
-    def run(self, name=None, no_check=False):
+    def run(self, name=None, no_check=False, verbose=False):
         from bzrlib.plugins.launchpad import account
         check_account = not no_check
 
@@ -233,6 +234,9 @@
             if username:
                 if check_account:
                     account.check_lp_login(username)
+                    if verbose:
+                        self.outf.write(
+                            "Launchpad user ID exists and has SSH keys.\n")
                 self.outf.write(username + '\n')
             else:
                 self.outf.write('No Launchpad user ID configured.\n')
@@ -241,7 +245,12 @@
             name = name.lower()
             if check_account:
                 account.check_lp_login(name)
+                if verbose:
+                    self.outf.write(
+                        "Launchpad user ID exists and has SSH keys.\n")
             account.set_lp_login(name)
+            if verbose:
+                self.outf.write("Launchpad user ID set to '%s'.\n" % (name,))
 
 register_command(cmd_launchpad_login)
 
@@ -259,6 +268,7 @@
     from bzrlib.plugins.launchpad import (
         test_account,
         test_lp_directory,
+        test_lp_login,
         test_lp_open,
         test_lp_service,
         test_register,
@@ -270,6 +280,7 @@
         test_account,
         test_register,
         test_lp_directory,
+        test_lp_login,
         test_lp_open,
         test_lp_service,
         ]:

=== added file 'bzrlib/plugins/launchpad/test_lp_login.py'
--- a/bzrlib/plugins/launchpad/test_lp_login.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/plugins/launchpad/test_lp_login.py	2009-07-03 09:16:06 +0000
@@ -0,0 +1,58 @@
+# Copyright (C) 2009 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+"""Tests for the launchpad-login command."""
+
+from bzrlib.plugins.launchpad import account
+from bzrlib.tests import TestCaseWithTransport
+
+
+class TestLaunchpadLogin(TestCaseWithTransport):
+    """Tests for launchpad-login."""
+
+    def test_login_without_name_when_not_logged_in(self):
+        # lp-login without a 'name' parameter returns the user ID of the
+        # logged in user. If no one is logged in, we tell the user as much.
+        out, err = self.run_bzr(['launchpad-login', '--no-check'], retcode=1)
+        self.assertEqual('No Launchpad user ID configured.\n', out)
+        self.assertEqual('', err)
+
+    def test_login_with_name_sets_login(self):
+        # lp-login with a 'name' parameter sets the Launchpad login.
+        self.run_bzr(['launchpad-login', '--no-check', 'foo'])
+        self.assertEqual('foo', account.get_lp_login())
+
+    def test_login_without_name_when_logged_in(self):
+        # lp-login without a 'name' parameter returns the user ID of the
+        # logged in user.
+        account.set_lp_login('foo')
+        out, err = self.run_bzr(['launchpad-login', '--no-check'])
+        self.assertEqual('foo\n', out)
+        self.assertEqual('', err)
+
+    def test_login_with_name_no_output_by_default(self):
+        # lp-login with a 'name' parameter produces no output by default.
+        out, err = self.run_bzr(['launchpad-login', '--no-check', 'foo'])
+        self.assertEqual('', out)
+        self.assertEqual('', err)
+
+    def test_login_with_name_verbose(self):
+        # lp-login with a 'name' parameter and a verbose flag produces some
+        # information about what Bazaar just did.
+        out, err = self.run_bzr(
+            ['launchpad-login', '-v', '--no-check', 'foo'])
+        self.assertEqual("Launchpad user ID set to 'foo'.\n", out)
+        self.assertEqual('', err)




More information about the bazaar-commits mailing list