1
# Copyright (C) 2009 Canonical Ltd
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.
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.
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
17
"""Tests for the launchpad-login command."""
19
from bzrlib.plugins.launchpad import account
20
from bzrlib.tests import TestCaseWithTransport
23
class TestLaunchpadLogin(TestCaseWithTransport):
24
"""Tests for launchpad-login."""
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)
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())
38
def test_login_without_name_when_logged_in(self):
39
# lp-login without a 'name' parameter returns the user ID of the
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)
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)
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)