/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
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
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
19
from . import account
20
from ...tests import TestCaseWithTransport
4505.1.1 by Jonathan Lange
First test for lp-login.
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)
7027.7.1 by Jelmer Vernooij
Fix launchpad plugin tests on python 3.
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'])
7027.7.1 by Jelmer Vernooij
Fix launchpad plugin tests on python 3.
43
        self.assertEqual('foo\n', out)
44
        self.assertEqual('', err)
4505.1.2 by Jonathan Lange
Add many more tests, fix the actual bug.
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'])
7027.7.1 by Jelmer Vernooij
Fix launchpad plugin tests on python 3.
49
        self.assertEqual('', out)
50
        self.assertEqual('', err)
4505.1.2 by Jonathan Lange
Add many more tests, fix the actual bug.
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'])
7027.7.1 by Jelmer Vernooij
Fix launchpad plugin tests on python 3.
57
        self.assertEqual("Launchpad user ID set to 'foo'.\n", out)
58
        self.assertEqual('', err)
6852.1.1 by Jelmer Vernooij
Add lp-logout command.
59
60
    def test_logout(self):
61
        out, err = self.run_bzr(
62
            ['launchpad-login', '-v', '--no-check', 'foo'])
7027.7.1 by Jelmer Vernooij
Fix launchpad plugin tests on python 3.
63
        self.assertEqual("Launchpad user ID set to 'foo'.\n", out)
64
        self.assertEqual('', err)
6852.1.1 by Jelmer Vernooij
Add lp-logout command.
65
66
        out, err = self.run_bzr(['launchpad-logout', '-v'])
7027.7.1 by Jelmer Vernooij
Fix launchpad plugin tests on python 3.
67
        self.assertEqual("Launchpad user ID foo logged out.\n", out)
68
        self.assertEqual('', err)
6852.1.1 by Jelmer Vernooij
Add lp-logout command.
69
70
    def test_logout_not_logged_in(self):
71
        out, err = self.run_bzr(['launchpad-logout', '-v'], retcode=1)
7027.7.1 by Jelmer Vernooij
Fix launchpad plugin tests on python 3.
72
        self.assertEqual('Not logged into Launchpad.\n', out)
73
        self.assertEqual("", err)