13
13
# You should have received a copy of the GNU General Public License
14
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
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
"""Tests for the launchpad-open command."""
19
from bzrlib.osutils import abspath
21
19
from bzrlib.tests import TestCaseWithTransport
29
27
return err.splitlines()
31
29
def test_non_branch(self):
32
# Running lp-open on a non-branch prints a simple error.
30
# If given a branch with no public or push locations, lp-open will try
31
# to guess the Launchpad page for the given URL / path. If it cannot
32
# find one, it will raise an error.
34
['bzr: ERROR: Not a branch: "%s/".' % abspath('.')],
34
['bzr: ERROR: . is not registered on Launchpad.'],
35
35
self.run_open('.', retcode=3))
37
def test_no_public_location(self):
37
def test_no_public_location_no_push_location(self):
38
38
self.make_branch('not-public')
40
['bzr: ERROR: There is no public branch set for "%s/".'
41
% abspath('not-public')],
40
['bzr: ERROR: not-public is not registered on Launchpad.'],
42
41
self.run_open('not-public', retcode=3))
44
43
def test_non_launchpad_branch(self):
46
45
url = 'http://example.com/non-lp'
47
46
branch.set_public_branch(url)
49
['bzr: ERROR: %s is not hosted on Launchpad.' % url],
48
['bzr: ERROR: %s is not registered on Launchpad.' % url],
50
49
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 '
51
def test_launchpad_branch_with_public_location(self):
52
branch = self.make_branch('lp')
53
branch.set_public_branch(
54
'bzr+ssh://bazaar.launchpad.net/~foo/bar/baz')
56
['Opening https://code.edge.launchpad.net/~foo/bar/baz in web '
60
def test_launchpad_branch_with_public_and_push_location(self):
61
branch = self.make_branch('lp')
62
branch.set_public_branch(
63
'bzr+ssh://bazaar.launchpad.net/~foo/bar/public')
64
branch.set_push_location(
65
'bzr+ssh://bazaar.launchpad.net/~foo/bar/push')
67
['Opening https://code.edge.launchpad.net/~foo/bar/public in web '
71
def test_launchpad_branch_with_no_public_but_with_push(self):
72
# lp-open falls back to the push location if it cannot find a public
74
branch = self.make_branch('lp')
75
branch.set_push_location(
76
'bzr+ssh://bazaar.launchpad.net/~foo/bar/baz')
78
['Opening https://code.edge.launchpad.net/~foo/bar/baz in web '
82
def test_launchpad_branch_with_no_public_no_push(self):
83
# If lp-open is given a branch URL and that branch has no public
84
# location and no push location, then just try to look up the
85
# Launchpad page for that URL.
87
['Opening https://code.edge.launchpad.net/~foo/bar/baz in web '
89
self.run_open('bzr+ssh://bazaar.launchpad.net/~foo/bar/baz'))