~bzr-pqm/bzr/bzr.dev

4505.1.1 by Jonathan Lange
First test for lp-login.
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
4505.1.2 by Jonathan Lange
Add many more tests, fix the actual bug.
19
from bzrlib.plugins.launchpad import account
4505.1.1 by Jonathan Lange
First test for lp-login.
20
from bzrlib.tests import TestCaseWithTransport
21
22
23
class TestLaunchpadLogin(TestCaseWithTransport):
24
    """Tests for launchpad-login."""
25
4505.1.2 by Jonathan Lange
Add many more tests, fix the actual bug.
26
    def test_login_without_name_when_not_logged_in(self):
4505.1.1 by Jonathan Lange
First test for lp-login.
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.
4505.1.2 by Jonathan Lange
Add many more tests, fix the actual bug.
29
        out, err = self.run_bzr(['launchpad-login', '--no-check'], retcode=1)
4505.1.1 by Jonathan Lange
First test for lp-login.
30
        self.assertEqual('No Launchpad user ID configured.\n', out)
31
        self.assertEqual('', err)
4505.1.2 by Jonathan Lange
Add many more tests, fix the actual bug.
32
33
    def test_login_with_name_sets_login(self):
34
        # lp-login with a 'name' parameter sets the Launchpad login.
4505.1.4 by Jonathan Lange
Use 'foo', not 'jml'
35
        self.run_bzr(['launchpad-login', '--no-check', 'foo'])
36
        self.assertEqual('foo', account.get_lp_login())
4505.1.2 by Jonathan Lange
Add many more tests, fix the actual bug.
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.
4505.1.4 by Jonathan Lange
Use 'foo', not 'jml'
41
        account.set_lp_login('foo')
4505.1.2 by Jonathan Lange
Add many more tests, fix the actual bug.
42
        out, err = self.run_bzr(['launchpad-login', '--no-check'])
4505.1.4 by Jonathan Lange
Use 'foo', not 'jml'
43
        self.assertEqual('foo\n', out)
4505.1.2 by Jonathan Lange
Add many more tests, fix the actual bug.
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.
4505.1.4 by Jonathan Lange
Use 'foo', not 'jml'
48
        out, err = self.run_bzr(['launchpad-login', '--no-check', 'foo'])
4505.1.2 by Jonathan Lange
Add many more tests, fix the actual bug.
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(
4505.1.4 by Jonathan Lange
Use 'foo', not 'jml'
56
            ['launchpad-login', '-v', '--no-check', 'foo'])
57
        self.assertEqual("Launchpad user ID set to 'foo'.\n", out)
4505.1.2 by Jonathan Lange
Add many more tests, fix the actual bug.
58
        self.assertEqual('', err)