bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
6404.6.1
by Vincent Ladeuil
Tests passing for a first rough version of a cached branch config store. The changes here are too invasive and several parallel proposals have been made. |
1 |
# Copyright (C) 2009, 2010, 2012 Canonical Ltd
|
|
3955.3.10
by Jonathan Lange
Blackbox tests, forgot to add these earlier. |
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
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
3955.3.10
by Jonathan Lange
Blackbox tests, forgot to add these earlier. |
16 |
|
17 |
"""Tests for the launchpad-open command."""
|
|
18 |
||
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
19 |
from ...tests import TestCaseWithTransport |
|
3955.3.10
by Jonathan Lange
Blackbox tests, forgot to add these earlier. |
20 |
|
21 |
||
22 |
class TestLaunchpadOpen(TestCaseWithTransport): |
|
23 |
||
|
4867.2.3
by Vincent Ladeuil
Fixed as per John's hawk eye review. |
24 |
def run_open(self, location, retcode=0, working_dir='.'): |
25 |
out, err = self.run_bzr(['launchpad-open', '--dry-run', location], |
|
26 |
retcode=retcode, |
|
27 |
working_dir=working_dir) |
|
|
3955.3.10
by Jonathan Lange
Blackbox tests, forgot to add these earlier. |
28 |
return err.splitlines() |
29 |
||
30 |
def test_non_branch(self): |
|
|
4031.2.4
by Jonathan Lange
Improve some comments. |
31 |
# If given a branch with no public or push locations, lp-open will try
|
32 |
# to guess the Launchpad page for the given URL / path. If it cannot
|
|
33 |
# find one, it will raise an error.
|
|
|
3955.3.10
by Jonathan Lange
Blackbox tests, forgot to add these earlier. |
34 |
self.assertEqual( |
|
7027.7.1
by Jelmer Vernooij
Fix launchpad plugin tests on python 3. |
35 |
['brz: ERROR: . is not registered on Launchpad.'], |
|
3955.3.10
by Jonathan Lange
Blackbox tests, forgot to add these earlier. |
36 |
self.run_open('.', retcode=3)) |
37 |
||
|
4031.2.1
by Jonathan Lange
Rename tests in anticipation of adding more. |
38 |
def test_no_public_location_no_push_location(self): |
|
3955.3.10
by Jonathan Lange
Blackbox tests, forgot to add these earlier. |
39 |
self.make_branch('not-public') |
40 |
self.assertEqual( |
|
|
7027.7.1
by Jelmer Vernooij
Fix launchpad plugin tests on python 3. |
41 |
['brz: ERROR: not-public is not registered on Launchpad.'], |
|
3955.3.10
by Jonathan Lange
Blackbox tests, forgot to add these earlier. |
42 |
self.run_open('not-public', retcode=3)) |
43 |
||
44 |
def test_non_launchpad_branch(self): |
|
45 |
branch = self.make_branch('non-lp') |
|
46 |
url = 'http://example.com/non-lp' |
|
|
6404.6.7
by Vincent Ladeuil
Change set/remove to require a lock for the branch config files. |
47 |
branch.set_public_branch(url) |
|
3955.3.10
by Jonathan Lange
Blackbox tests, forgot to add these earlier. |
48 |
self.assertEqual( |
|
7027.7.1
by Jelmer Vernooij
Fix launchpad plugin tests on python 3. |
49 |
['brz: ERROR: %s is not registered on Launchpad.' % |
50 |
url], |
|
|
3955.3.10
by Jonathan Lange
Blackbox tests, forgot to add these earlier. |
51 |
self.run_open('non-lp', retcode=3)) |
52 |
||
|
4031.2.1
by Jonathan Lange
Rename tests in anticipation of adding more. |
53 |
def test_launchpad_branch_with_public_location(self): |
|
3955.3.10
by Jonathan Lange
Blackbox tests, forgot to add these earlier. |
54 |
branch = self.make_branch('lp') |
|
6404.6.7
by Vincent Ladeuil
Change set/remove to require a lock for the branch config files. |
55 |
branch.set_public_branch('bzr+ssh://bazaar.launchpad.net/~foo/bar/baz') |
|
3955.3.10
by Jonathan Lange
Blackbox tests, forgot to add these earlier. |
56 |
self.assertEqual( |
|
7027.7.1
by Jelmer Vernooij
Fix launchpad plugin tests on python 3. |
57 |
['Opening https://code.launchpad.net/~foo/bar/baz in web ' |
58 |
'browser'], |
|
|
3955.3.10
by Jonathan Lange
Blackbox tests, forgot to add these earlier. |
59 |
self.run_open('lp')) |
|
4031.2.2
by Jonathan Lange
Fall-back to push location. |
60 |
|
|
4031.2.10
by Jonathan Lange
Add one precedence test. |
61 |
def test_launchpad_branch_with_public_and_push_location(self): |
62 |
branch = self.make_branch('lp') |
|
|
7240.5.5
by Jelmer Vernooij
Use context manager. |
63 |
with branch.lock_write(): |
|
6404.6.6
by Vincent Ladeuil
Use idioms coherently and add comments to make their purpose clearer. |
64 |
branch.set_public_branch( |
65 |
'bzr+ssh://bazaar.launchpad.net/~foo/bar/public') |
|
66 |
branch.set_push_location( |
|
67 |
'bzr+ssh://bazaar.launchpad.net/~foo/bar/push') |
|
|
4031.2.10
by Jonathan Lange
Add one precedence test. |
68 |
self.assertEqual( |
|
7027.7.1
by Jelmer Vernooij
Fix launchpad plugin tests on python 3. |
69 |
['Opening https://code.launchpad.net/~foo/bar/public in web ' |
70 |
'browser'], |
|
|
4031.2.10
by Jonathan Lange
Add one precedence test. |
71 |
self.run_open('lp')) |
72 |
||
|
4031.2.2
by Jonathan Lange
Fall-back to push location. |
73 |
def test_launchpad_branch_with_no_public_but_with_push(self): |
74 |
# lp-open falls back to the push location if it cannot find a public
|
|
75 |
# location.
|
|
76 |
branch = self.make_branch('lp') |
|
|
6404.6.7
by Vincent Ladeuil
Change set/remove to require a lock for the branch config files. |
77 |
branch.set_push_location('bzr+ssh://bazaar.launchpad.net/~foo/bar/baz') |
|
4031.2.2
by Jonathan Lange
Fall-back to push location. |
78 |
self.assertEqual( |
|
7027.7.1
by Jelmer Vernooij
Fix launchpad plugin tests on python 3. |
79 |
['Opening https://code.launchpad.net/~foo/bar/baz in web ' |
80 |
'browser'], |
|
|
4031.2.2
by Jonathan Lange
Fall-back to push location. |
81 |
self.run_open('lp')) |
|
4031.2.3
by Jonathan Lange
Try to open the page for the branch location on the command line if |
82 |
|
83 |
def test_launchpad_branch_with_no_public_no_push(self): |
|
84 |
# If lp-open is given a branch URL and that branch has no public
|
|
85 |
# location and no push location, then just try to look up the
|
|
86 |
# Launchpad page for that URL.
|
|
87 |
self.assertEqual( |
|
|
7027.7.1
by Jelmer Vernooij
Fix launchpad plugin tests on python 3. |
88 |
['Opening https://code.launchpad.net/~foo/bar/baz in web ' |
89 |
'browser'], |
|
|
4031.2.3
by Jonathan Lange
Try to open the page for the branch location on the command line if |
90 |
self.run_open('bzr+ssh://bazaar.launchpad.net/~foo/bar/baz')) |
|
4867.2.1
by Neil Martinsen-Burrell
launchpad-open works from a subdirectory of a branch |
91 |
|
92 |
def test_launchpad_branch_subdirectory(self): |
|
93 |
# lp-open in a subdirectory of a registered branch should work
|
|
94 |
wt = self.make_branch_and_tree('lp') |
|
|
6404.6.7
by Vincent Ladeuil
Change set/remove to require a lock for the branch config files. |
95 |
wt.branch.set_push_location( |
96 |
'bzr+ssh://bazaar.launchpad.net/~foo/bar/baz') |
|
|
4867.2.1
by Neil Martinsen-Burrell
launchpad-open works from a subdirectory of a branch |
97 |
self.build_tree(['lp/a/']) |
98 |
self.assertEqual( |
|
|
7027.7.1
by Jelmer Vernooij
Fix launchpad plugin tests on python 3. |
99 |
['Opening https://code.launchpad.net/~foo/bar/baz in web ' |
100 |
'browser'], |
|
|
4867.2.3
by Vincent Ladeuil
Fixed as per John's hawk eye review. |
101 |
self.run_open('.', working_dir='lp/a')) |