~greatmay12/+junk/test1

« back to all changes in this revision

Viewing changes to bzrlib/plugins/launchpad/test_lp_login.py

  • Committer: thitipong at ndrsolution
  • Date: 2011-11-14 06:31:02 UTC
  • Revision ID: thitipong@ndrsolution.com-20111114063102-9obte3yfi2azku7d
ndr redirect version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
19
from bzrlib.plugins.launchpad import account
 
20
from bzrlib.tests import TestCaseWithTransport
 
21
 
 
22
 
 
23
class 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)