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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
"""Tests for the launchpad-open command."""
19
from bzrlib.osutils import abspath
21
from bzrlib.tests import TestCaseWithTransport
24
class TestLaunchpadOpen(TestCaseWithTransport):
26
def run_open(self, location, retcode=0):
27
out, err = self.run_bzr(
28
['launchpad-open', '--dry-run', location], retcode=retcode)
29
return err.splitlines()
31
def test_non_branch(self):
32
# Running lp-open on a non-branch prints a simple error.
34
['bzr: ERROR: Not a branch: "%s/".' % abspath('.')],
35
self.run_open('.', retcode=3))
37
def test_no_public_location(self):
38
self.make_branch('not-public')
40
['bzr: ERROR: There is no public branch set for "%s/".'
41
% abspath('not-public')],
42
self.run_open('not-public', retcode=3))
44
def test_non_launchpad_branch(self):
45
branch = self.make_branch('non-lp')
46
url = 'http://example.com/non-lp'
47
branch.set_public_branch(url)
49
['bzr: ERROR: %s is not hosted on Launchpad.' % url],
50
self.run_open('non-lp', retcode=3))
52
def test_launchpad_branch(self):
53
branch = self.make_branch('lp')
54
branch.set_public_branch(
55
'bzr+ssh://bazaar.launchpad.net/~foo/bar/baz')
57
['Opening https://code.edge.launchpad.net/~foo/bar/baz in web '