bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2007-2012, 2016 Canonical Ltd
|
2245.8.1
by Martin Pool
Start adding tests for launchpad indirection |
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
|
2245.8.1
by Martin Pool
Start adding tests for launchpad indirection |
16 |
|
3251.4.3
by Aaron Bentley
More renames and cleanups |
17 |
"""Tests for directory lookup through Launchpad.net"""
|
2245.8.1
by Martin Pool
Start adding tests for launchpad indirection |
18 |
|
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
19 |
import os |
6973.12.9
by Jelmer Vernooij
More fixes. |
20 |
|
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
21 |
from xmlrpc.client import Fault |
22 |
from http.client import parse_headers |
|
2898.4.4
by James Henstridge
Changes to account for modifications to the XMLRPC API. |
23 |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
24 |
import breezy |
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
25 |
from ... import ( |
5609.24.11
by John Arbash Meinel
If someone uses -Dlaunchpad, use the 'official' URL instead of the local one. |
26 |
debug, |
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
27 |
tests, |
5273.1.7
by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through |
28 |
transport, |
2245.8.3
by Martin Pool
Start adding indirection transport |
29 |
)
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
30 |
from ...branch import Branch |
31 |
from ...directory_service import directories |
|
32 |
from ...tests import ( |
|
5967.12.5
by Martin Pool
Update launchpad plugin for features under tests.features |
33 |
features, |
6238.2.24
by Vincent Ladeuil
Fix the last test failure by providing the test ca certs via the config option framework. |
34 |
ssl_certs, |
3777.1.18
by Aaron Bentley
Fix None handling wrt auth upgrades |
35 |
TestCaseInTempDir, |
36 |
TestCaseWithMemoryTransport
|
|
37 |
)
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
38 |
from . import ( |
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
39 |
_register_directory, |
40 |
lp_registration, |
|
41 |
)
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
42 |
from .lp_directory import ( |
3251.4.1
by Aaron Bentley
Convert LP transport into directory service |
43 |
LaunchpadDirectory) |
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
44 |
from .account import get_lp_login, set_lp_login |
45 |
from ...tests import http_server |
|
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
46 |
|
47 |
||
6625.1.5
by Martin
Drop custom load_tests implementation and use unittest signature |
48 |
def load_tests(loader, standard_tests, pattern): |
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
49 |
result = loader.suiteClass() |
50 |
t_tests, remaining_tests = tests.split_suite_by_condition( |
|
51 |
standard_tests, tests.condition_isinstance(( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
52 |
TestXMLRPCTransport, |
53 |
)))
|
|
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
54 |
transport_scenarios = [ |
55 |
('http', dict(server_class=PreCannedHTTPServer,)), |
|
56 |
]
|
|
5967.12.5
by Martin Pool
Update launchpad plugin for features under tests.features |
57 |
if features.HTTPSServerFeature.available(): |
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
58 |
transport_scenarios.append( |
59 |
('https', dict(server_class=PreCannedHTTPSServer,)), |
|
60 |
)
|
|
61 |
tests.multiply_tests(t_tests, transport_scenarios, result) |
|
62 |
||
63 |
# No parametrization for the remaining tests
|
|
64 |
result.addTests(remaining_tests) |
|
65 |
||
66 |
return result |
|
2898.4.3
by James Henstridge
Make launchpad_transport_indirect() use XMLRPC to resolve the lp: URL. |
67 |
|
68 |
||
69 |
class FakeResolveFactory(object): |
|
5609.24.9
by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution. |
70 |
|
2898.4.3
by James Henstridge
Make launchpad_transport_indirect() use XMLRPC to resolve the lp: URL. |
71 |
def __init__(self, test, expected_path, result): |
72 |
self._test = test |
|
73 |
self._expected_path = expected_path |
|
74 |
self._result = result |
|
5609.24.9
by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution. |
75 |
self._submitted = False |
2898.4.3
by James Henstridge
Make launchpad_transport_indirect() use XMLRPC to resolve the lp: URL. |
76 |
|
77 |
def __call__(self, path): |
|
78 |
self._test.assertEqual(self._expected_path, path) |
|
79 |
return self |
|
80 |
||
81 |
def submit(self, service): |
|
3193.5.2
by Tim Penhey
Updated the tests to handle unknown launchpad instances. |
82 |
self._service_url = service.service_url |
5609.24.9
by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution. |
83 |
self._submitted = True |
2898.4.3
by James Henstridge
Make launchpad_transport_indirect() use XMLRPC to resolve the lp: URL. |
84 |
return self._result |
2245.8.1
by Martin Pool
Start adding tests for launchpad indirection |
85 |
|
2245.8.7
by Martin Pool
small review cleanups |
86 |
|
5609.24.9
by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution. |
87 |
class LocalDirectoryURLTests(TestCaseInTempDir): |
88 |
"""Tests for branch urls that we try to pass through local resolution.""" |
|
89 |
||
90 |
def assertResolve(self, expected, url, submitted=False): |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
91 |
path = url[url.index(':') + 1:].lstrip('/') |
5609.24.9
by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution. |
92 |
factory = FakeResolveFactory(self, path, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
93 |
dict(urls=['bzr+ssh://fake-resolved'])) |
5609.24.9
by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution. |
94 |
directory = LaunchpadDirectory() |
95 |
self.assertEqual(expected, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
96 |
directory._resolve(url, factory, _lp_login='user')) |
5609.24.9
by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution. |
97 |
# We are testing local resolution, and the fallback when necessary.
|
98 |
self.assertEqual(submitted, factory._submitted) |
|
99 |
||
100 |
def test_short_form(self): |
|
101 |
self.assertResolve('bzr+ssh://bazaar.launchpad.net/+branch/apt', |
|
102 |
'lp:apt') |
|
103 |
||
7240.11.1
by Jelmer Vernooij
Add support for lp+bzr. |
104 |
def test_short_form_bzr(self): |
105 |
self.assertResolve('bzr+ssh://bazaar.launchpad.net/+branch/apt', |
|
106 |
'lp+bzr:apt') |
|
107 |
||
5609.24.9
by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution. |
108 |
def test_two_part_form(self): |
109 |
self.assertResolve('bzr+ssh://bazaar.launchpad.net/+branch/apt/2.2', |
|
110 |
'lp:apt/2.2') |
|
111 |
||
112 |
def test_two_part_plus_subdir(self): |
|
113 |
# We allow you to pass more than just what resolves. That way you can
|
|
6622.1.30
by Jelmer Vernooij
Some more test fixes. |
114 |
# do things like "brz log lp:apt/2.2/BUGS"
|
5609.24.9
by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution. |
115 |
# Though the virtual FS implementation currently aborts when given a
|
116 |
# URL like this, rather than letting you recurse upwards to find the
|
|
117 |
# real branch at lp:apt/2.2
|
|
118 |
self.assertResolve('bzr+ssh://bazaar.launchpad.net/+branch/apt/2.2/BUGS', |
|
119 |
'lp:apt/2.2/BUGS') |
|
120 |
||
121 |
def test_user_expansion(self): |
|
122 |
self.assertResolve('bzr+ssh://bazaar.launchpad.net/~user/apt/foo', |
|
123 |
'lp:~/apt/foo') |
|
124 |
||
125 |
def test_ubuntu(self): |
|
126 |
# Confirmed against xmlrpc. If you don't have a ~user, xmlrpc doesn't
|
|
127 |
# care that you are asking for 'ubuntu'
|
|
128 |
self.assertResolve('bzr+ssh://bazaar.launchpad.net/+branch/ubuntu', |
|
129 |
'lp:ubuntu') |
|
130 |
||
6191.2.1
by Martin Pool
Avoid NameError when given an invalid ubuntu: launchpad url |
131 |
def test_ubuntu_invalid(self): |
132 |
"""Invalid ubuntu urls don't crash. |
|
133 |
||
134 |
:seealso: http://pad.lv/843900
|
|
135 |
"""
|
|
136 |
# This ought to be natty-updates.
|
|
6729.6.1
by Jelmer Vernooij
Move urlutils errors. |
137 |
self.assertRaises(lp_registration.InvalidURL, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
138 |
self.assertResolve, |
139 |
'', |
|
140 |
'ubuntu:natty/updates/smartpm') |
|
6191.2.1
by Martin Pool
Avoid NameError when given an invalid ubuntu: launchpad url |
141 |
|
5609.24.9
by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution. |
142 |
def test_ubuntu_apt(self): |
143 |
self.assertResolve('bzr+ssh://bazaar.launchpad.net/+branch/ubuntu/apt', |
|
144 |
'lp:ubuntu/apt') |
|
145 |
||
146 |
def test_ubuntu_natty_apt(self): |
|
147 |
self.assertResolve( |
|
148 |
'bzr+ssh://bazaar.launchpad.net/+branch/ubuntu/natty/apt', |
|
149 |
'lp:ubuntu/natty/apt') |
|
150 |
||
151 |
def test_ubuntu_natty_apt_filename(self): |
|
152 |
self.assertResolve( |
|
153 |
'bzr+ssh://bazaar.launchpad.net/+branch/ubuntu/natty/apt/filename', |
|
154 |
'lp:ubuntu/natty/apt/filename') |
|
155 |
||
156 |
def test_user_two_part(self): |
|
157 |
# We fall back to the ResolveFactory. The real Launchpad one will raise
|
|
158 |
# InvalidURL for this case.
|
|
159 |
self.assertResolve('bzr+ssh://fake-resolved', 'lp:~jameinel/apt', |
|
160 |
submitted=True) |
|
161 |
||
162 |
def test_user_three_part(self): |
|
163 |
self.assertResolve('bzr+ssh://bazaar.launchpad.net/~jameinel/apt/foo', |
|
164 |
'lp:~jameinel/apt/foo') |
|
165 |
||
166 |
def test_user_three_part_plus_filename(self): |
|
167 |
self.assertResolve( |
|
168 |
'bzr+ssh://bazaar.launchpad.net/~jameinel/apt/foo/fname', |
|
169 |
'lp:~jameinel/apt/foo/fname') |
|
170 |
||
171 |
def test_user_ubuntu_two_part(self): |
|
172 |
self.assertResolve('bzr+ssh://fake-resolved', 'lp:~jameinel/ubuntu', |
|
173 |
submitted=True) |
|
174 |
self.assertResolve('bzr+ssh://fake-resolved', 'lp:~jameinel/debian', |
|
175 |
submitted=True) |
|
176 |
||
177 |
def test_user_ubuntu_three_part(self): |
|
178 |
self.assertResolve('bzr+ssh://fake-resolved', |
|
179 |
'lp:~jameinel/ubuntu/natty', submitted=True) |
|
180 |
self.assertResolve('bzr+ssh://fake-resolved', |
|
181 |
'lp:~jameinel/debian/sid', submitted=True) |
|
182 |
||
183 |
def test_user_ubuntu_four_part(self): |
|
184 |
self.assertResolve('bzr+ssh://fake-resolved', |
|
185 |
'lp:~jameinel/ubuntu/natty/project', submitted=True) |
|
186 |
self.assertResolve('bzr+ssh://fake-resolved', |
|
187 |
'lp:~jameinel/debian/sid/project', submitted=True) |
|
188 |
||
189 |
def test_user_ubuntu_five_part(self): |
|
190 |
self.assertResolve( |
|
191 |
'bzr+ssh://bazaar.launchpad.net/~jameinel/ubuntu/natty/apt/branch', |
|
192 |
'lp:~jameinel/ubuntu/natty/apt/branch') |
|
193 |
self.assertResolve( |
|
194 |
'bzr+ssh://bazaar.launchpad.net/~jameinel/debian/sid/apt/branch', |
|
195 |
'lp:~jameinel/debian/sid/apt/branch') |
|
196 |
||
197 |
def test_user_ubuntu_five_part_plus_subdir(self): |
|
198 |
self.assertResolve( |
|
199 |
'bzr+ssh://bazaar.launchpad.net/~jameinel/ubuntu/natty/apt/branch/f', |
|
200 |
'lp:~jameinel/ubuntu/natty/apt/branch/f') |
|
201 |
self.assertResolve( |
|
202 |
'bzr+ssh://bazaar.launchpad.net/~jameinel/debian/sid/apt/branch/f', |
|
203 |
'lp:~jameinel/debian/sid/apt/branch/f') |
|
204 |
||
205 |
def test_handles_special_lp(self): |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
206 |
self.assertResolve( |
207 |
'bzr+ssh://bazaar.launchpad.net/+branch/apt', 'lp:apt') |
|
5609.24.9
by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution. |
208 |
self.assertResolve('bzr+ssh://bazaar.launchpad.net/+branch/apt', |
209 |
'lp:///apt') |
|
210 |
self.assertResolve('bzr+ssh://bazaar.launchpad.net/+branch/apt', |
|
211 |
'lp://production/apt') |
|
7413.1.2
by Vincent Ladeuil
Fix test failures caused by divergence between lp:brz and lp:brz/3.0 |
212 |
self.assertResolve('bzr+ssh://bazaar.launchpad.dev/+branch/apt', |
5609.24.9
by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution. |
213 |
'lp://dev/apt') |
214 |
self.assertResolve('bzr+ssh://bazaar.staging.launchpad.net/+branch/apt', |
|
215 |
'lp://staging/apt') |
|
216 |
self.assertResolve('bzr+ssh://bazaar.qastaging.launchpad.net/+branch/apt', |
|
217 |
'lp://qastaging/apt') |
|
218 |
self.assertResolve('bzr+ssh://bazaar.demo.launchpad.net/+branch/apt', |
|
219 |
'lp://demo/apt') |
|
220 |
||
5609.24.11
by John Arbash Meinel
If someone uses -Dlaunchpad, use the 'official' URL instead of the local one. |
221 |
def test_debug_launchpad_uses_resolver(self): |
222 |
self.assertResolve('bzr+ssh://bazaar.launchpad.net/+branch/bzr', |
|
223 |
'lp:bzr', submitted=False) |
|
224 |
debug.debug_flags.add('launchpad') |
|
225 |
self.addCleanup(debug.debug_flags.discard, 'launchpad') |
|
226 |
self.assertResolve('bzr+ssh://fake-resolved', 'lp:bzr', submitted=True) |
|
5609.24.9
by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution. |
227 |
|
228 |
||
3777.1.18
by Aaron Bentley
Fix None handling wrt auth upgrades |
229 |
class DirectoryUrlTests(TestCaseInTempDir): |
3251.4.3
by Aaron Bentley
More renames and cleanups |
230 |
"""Tests for branch urls through Launchpad.net directory""" |
2245.8.1
by Martin Pool
Start adding tests for launchpad indirection |
231 |
|
2245.8.5
by Martin Pool
Add short-form lp:PRODUCT url form |
232 |
def test_short_form(self): |
233 |
"""A launchpad url should map to a http url""" |
|
2898.4.3
by James Henstridge
Make launchpad_transport_indirect() use XMLRPC to resolve the lp: URL. |
234 |
factory = FakeResolveFactory( |
2898.4.4
by James Henstridge
Changes to account for modifications to the XMLRPC API. |
235 |
self, 'apt', dict(urls=[ |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
236 |
'http://bazaar.launchpad.net/~apt/apt/devel'])) |
3251.4.1
by Aaron Bentley
Convert LP transport into directory service |
237 |
directory = LaunchpadDirectory() |
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
238 |
self.assertEqual('http://bazaar.launchpad.net/~apt/apt/devel', |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
239 |
directory._resolve('lp:apt', factory)) |
3193.5.2
by Tim Penhey
Updated the tests to handle unknown launchpad instances. |
240 |
# Make sure that resolve went to the production server.
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
241 |
self.assertEqual('https://xmlrpc.launchpad.net/bazaar/', |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
242 |
factory._service_url) |
3193.5.2
by Tim Penhey
Updated the tests to handle unknown launchpad instances. |
243 |
|
5615.2.1
by Jelmer Vernooij
Support the 'qastaging' instance of Launchpad. |
244 |
def test_qastaging(self): |
245 |
"""A launchpad url should map to a http url""" |
|
246 |
factory = FakeResolveFactory( |
|
247 |
self, 'apt', dict(urls=[ |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
248 |
'http://bazaar.qastaging.launchpad.net/~apt/apt/devel'])) |
5615.2.1
by Jelmer Vernooij
Support the 'qastaging' instance of Launchpad. |
249 |
url = 'lp://qastaging/apt' |
250 |
directory = LaunchpadDirectory() |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
251 |
self.assertEqual('http://bazaar.qastaging.launchpad.net/~apt/apt/devel', |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
252 |
directory._resolve(url, factory)) |
5615.2.1
by Jelmer Vernooij
Support the 'qastaging' instance of Launchpad. |
253 |
# Make sure that resolve went to the qastaging server.
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
254 |
self.assertEqual('https://xmlrpc.qastaging.launchpad.net/bazaar/', |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
255 |
factory._service_url) |
5615.2.1
by Jelmer Vernooij
Support the 'qastaging' instance of Launchpad. |
256 |
|
3193.5.2
by Tim Penhey
Updated the tests to handle unknown launchpad instances. |
257 |
def test_staging(self): |
258 |
"""A launchpad url should map to a http url""" |
|
259 |
factory = FakeResolveFactory( |
|
260 |
self, 'apt', dict(urls=[ |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
261 |
'http://bazaar.staging.launchpad.net/~apt/apt/devel'])) |
3193.5.2
by Tim Penhey
Updated the tests to handle unknown launchpad instances. |
262 |
url = 'lp://staging/apt' |
3251.4.1
by Aaron Bentley
Convert LP transport into directory service |
263 |
directory = LaunchpadDirectory() |
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
264 |
self.assertEqual('http://bazaar.staging.launchpad.net/~apt/apt/devel', |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
265 |
directory._resolve(url, factory)) |
3193.5.2
by Tim Penhey
Updated the tests to handle unknown launchpad instances. |
266 |
# Make sure that resolve went to the staging server.
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
267 |
self.assertEqual('https://xmlrpc.staging.launchpad.net/bazaar/', |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
268 |
factory._service_url) |
2245.8.5
by Martin Pool
Add short-form lp:PRODUCT url form |
269 |
|
3251.4.3
by Aaron Bentley
More renames and cleanups |
270 |
def test_url_from_directory(self): |
2245.8.3
by Martin Pool
Start adding indirection transport |
271 |
"""A launchpad url should map to a http url""" |
2898.4.3
by James Henstridge
Make launchpad_transport_indirect() use XMLRPC to resolve the lp: URL. |
272 |
factory = FakeResolveFactory( |
2898.4.4
by James Henstridge
Changes to account for modifications to the XMLRPC API. |
273 |
self, 'apt', dict(urls=[ |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
274 |
'http://bazaar.launchpad.net/~apt/apt/devel'])) |
3251.4.1
by Aaron Bentley
Convert LP transport into directory service |
275 |
directory = LaunchpadDirectory() |
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
276 |
self.assertEqual('http://bazaar.launchpad.net/~apt/apt/devel', |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
277 |
directory._resolve('lp:///apt', factory)) |
2898.4.3
by James Henstridge
Make launchpad_transport_indirect() use XMLRPC to resolve the lp: URL. |
278 |
|
3251.4.3
by Aaron Bentley
More renames and cleanups |
279 |
def test_directory_skip_bad_schemes(self): |
2898.4.9
by James Henstridge
Add some more tests for the bzr+ssh://bazaar.launchpad.net URL |
280 |
factory = FakeResolveFactory( |
281 |
self, 'apt', dict(urls=[ |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
282 |
'bad-scheme://bazaar.launchpad.net/~apt/apt/devel', |
283 |
'http://bazaar.launchpad.net/~apt/apt/devel', |
|
284 |
'http://another/location'])) |
|
3251.4.1
by Aaron Bentley
Convert LP transport into directory service |
285 |
directory = LaunchpadDirectory() |
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
286 |
self.assertEqual('http://bazaar.launchpad.net/~apt/apt/devel', |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
287 |
directory._resolve('lp:///apt', factory)) |
2898.4.9
by James Henstridge
Add some more tests for the bzr+ssh://bazaar.launchpad.net URL |
288 |
|
3251.4.3
by Aaron Bentley
More renames and cleanups |
289 |
def test_directory_no_matching_schemes(self): |
2898.4.3
by James Henstridge
Make launchpad_transport_indirect() use XMLRPC to resolve the lp: URL. |
290 |
# If the XMLRPC call does not return any protocols we support,
|
291 |
# invalidURL is raised.
|
|
292 |
factory = FakeResolveFactory( |
|
2898.4.4
by James Henstridge
Changes to account for modifications to the XMLRPC API. |
293 |
self, 'apt', dict(urls=[ |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
294 |
'bad-scheme://bazaar.launchpad.net/~apt/apt/devel'])) |
3251.4.1
by Aaron Bentley
Convert LP transport into directory service |
295 |
directory = LaunchpadDirectory() |
6729.6.1
by Jelmer Vernooij
Move urlutils errors. |
296 |
self.assertRaises(lp_registration.InvalidURL, |
3251.4.1
by Aaron Bentley
Convert LP transport into directory service |
297 |
directory._resolve, 'lp:///apt', factory) |
2898.4.4
by James Henstridge
Changes to account for modifications to the XMLRPC API. |
298 |
|
3251.4.3
by Aaron Bentley
More renames and cleanups |
299 |
def test_directory_fault(self): |
2898.4.4
by James Henstridge
Changes to account for modifications to the XMLRPC API. |
300 |
# Test that XMLRPC faults get converted to InvalidURL errors.
|
301 |
factory = FakeResolveFactory(self, 'apt', None) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
302 |
|
2898.4.4
by James Henstridge
Changes to account for modifications to the XMLRPC API. |
303 |
def submit(service): |
6973.12.9
by Jelmer Vernooij
More fixes. |
304 |
raise Fault(42, 'something went wrong') |
2898.4.4
by James Henstridge
Changes to account for modifications to the XMLRPC API. |
305 |
factory.submit = submit |
3251.4.1
by Aaron Bentley
Convert LP transport into directory service |
306 |
directory = LaunchpadDirectory() |
6729.6.1
by Jelmer Vernooij
Move urlutils errors. |
307 |
self.assertRaises(lp_registration.InvalidURL, |
3251.4.1
by Aaron Bentley
Convert LP transport into directory service |
308 |
directory._resolve, 'lp:///apt', factory) |
2245.8.4
by Martin Pool
lp:/// indirection works |
309 |
|
2898.4.9
by James Henstridge
Add some more tests for the bzr+ssh://bazaar.launchpad.net URL |
310 |
def test_skip_bzr_ssh_launchpad_net_when_anonymous(self): |
311 |
# Test that bzr+ssh://bazaar.launchpad.net gets skipped if
|
|
312 |
# Bazaar does not know the user's Launchpad ID:
|
|
313 |
self.assertEqual(None, get_lp_login()) |
|
314 |
factory = FakeResolveFactory( |
|
315 |
self, 'apt', dict(urls=[ |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
316 |
'bzr+ssh://bazaar.launchpad.net/~apt/apt/devel', |
317 |
'http://bazaar.launchpad.net/~apt/apt/devel'])) |
|
3251.4.1
by Aaron Bentley
Convert LP transport into directory service |
318 |
directory = LaunchpadDirectory() |
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
319 |
self.assertEqual('http://bazaar.launchpad.net/~apt/apt/devel', |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
320 |
directory._resolve('lp:///apt', factory)) |
2898.4.9
by James Henstridge
Add some more tests for the bzr+ssh://bazaar.launchpad.net URL |
321 |
|
3031.2.2
by jml at canonical
Failing test for skipping SFTP. |
322 |
def test_skip_sftp_launchpad_net_when_anonymous(self): |
323 |
# Test that sftp://bazaar.launchpad.net gets skipped if
|
|
324 |
# Bazaar does not know the user's Launchpad ID:
|
|
325 |
self.assertEqual(None, get_lp_login()) |
|
326 |
factory = FakeResolveFactory( |
|
327 |
self, 'apt', dict(urls=[ |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
328 |
'sftp://bazaar.launchpad.net/~apt/apt/devel', |
329 |
'http://bazaar.launchpad.net/~apt/apt/devel'])) |
|
3251.4.1
by Aaron Bentley
Convert LP transport into directory service |
330 |
directory = LaunchpadDirectory() |
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
331 |
self.assertEqual('http://bazaar.launchpad.net/~apt/apt/devel', |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
332 |
directory._resolve('lp:///apt', factory)) |
3031.2.2
by jml at canonical
Failing test for skipping SFTP. |
333 |
|
5609.24.8
by John Arbash Meinel
Fix the launchpad-login tests. And fix a bad commit typo. |
334 |
def test_with_login_avoid_resolve_factory(self): |
2898.4.9
by James Henstridge
Add some more tests for the bzr+ssh://bazaar.launchpad.net URL |
335 |
# Test that bzr+ssh URLs get rewritten to include the user's
|
336 |
# Launchpad ID (assuming we know the Launchpad ID).
|
|
337 |
factory = FakeResolveFactory( |
|
338 |
self, 'apt', dict(urls=[ |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
339 |
'bzr+ssh://my-super-custom/special/devel', |
340 |
'http://bazaar.launchpad.net/~apt/apt/devel'])) |
|
3251.4.1
by Aaron Bentley
Convert LP transport into directory service |
341 |
directory = LaunchpadDirectory() |
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
342 |
self.assertEqual( |
5609.24.8
by John Arbash Meinel
Fix the launchpad-login tests. And fix a bad commit typo. |
343 |
'bzr+ssh://bazaar.launchpad.net/+branch/apt', |
3251.4.1
by Aaron Bentley
Convert LP transport into directory service |
344 |
directory._resolve('lp:///apt', factory, _lp_login='username')) |
2898.4.9
by James Henstridge
Add some more tests for the bzr+ssh://bazaar.launchpad.net URL |
345 |
|
346 |
def test_no_rewrite_of_other_bzr_ssh(self): |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
347 |
# Test that we don't rewrite bzr+ssh URLs for other
|
2898.4.9
by James Henstridge
Add some more tests for the bzr+ssh://bazaar.launchpad.net URL |
348 |
self.assertEqual(None, get_lp_login()) |
349 |
factory = FakeResolveFactory( |
|
350 |
self, 'apt', dict(urls=[ |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
351 |
'bzr+ssh://example.com/~apt/apt/devel', |
352 |
'http://bazaar.launchpad.net/~apt/apt/devel'])) |
|
3251.4.1
by Aaron Bentley
Convert LP transport into directory service |
353 |
directory = LaunchpadDirectory() |
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
354 |
self.assertEqual('bzr+ssh://example.com/~apt/apt/devel', |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
355 |
directory._resolve('lp:///apt', factory)) |
2898.4.9
by James Henstridge
Add some more tests for the bzr+ssh://bazaar.launchpad.net URL |
356 |
|
2245.8.4
by Martin Pool
lp:/// indirection works |
357 |
# TODO: check we get an error if the url is unreasonable
|
3251.4.3
by Aaron Bentley
More renames and cleanups |
358 |
def test_error_for_bad_url(self): |
3251.4.1
by Aaron Bentley
Convert LP transport into directory service |
359 |
directory = LaunchpadDirectory() |
6729.6.1
by Jelmer Vernooij
Move urlutils errors. |
360 |
self.assertRaises(lp_registration.InvalidURL, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
361 |
directory._resolve, 'lp://ratotehunoahu') |
2898.4.12
by James Henstridge
Add tests that redirects get issued by appropriate transport methods. |
362 |
|
5361.1.1
by John Arbash Meinel
Handle a simple ~ in lp: urls. |
363 |
def test_resolve_tilde_to_user(self): |
364 |
factory = FakeResolveFactory( |
|
365 |
self, '~username/apt/test', dict(urls=[ |
|
5609.24.9
by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution. |
366 |
'bzr+ssh://bazaar.launchpad.net/~username/apt/test'])) |
5361.1.1
by John Arbash Meinel
Handle a simple ~ in lp: urls. |
367 |
directory = LaunchpadDirectory() |
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
368 |
self.assertEqual( |
5609.24.9
by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution. |
369 |
'bzr+ssh://bazaar.launchpad.net/~username/apt/test', |
5361.1.1
by John Arbash Meinel
Handle a simple ~ in lp: urls. |
370 |
directory._resolve('lp:~/apt/test', factory, _lp_login='username')) |
371 |
# Should also happen when the login is just set by config
|
|
372 |
set_lp_login('username') |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
373 |
self.assertEqual( |
5609.24.9
by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution. |
374 |
'bzr+ssh://bazaar.launchpad.net/~username/apt/test', |
5361.1.1
by John Arbash Meinel
Handle a simple ~ in lp: urls. |
375 |
directory._resolve('lp:~/apt/test', factory)) |
376 |
||
377 |
def test_tilde_fails_no_login(self): |
|
378 |
factory = FakeResolveFactory( |
|
379 |
self, '~username/apt/test', dict(urls=[ |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
380 |
'bzr+ssh://bazaar.launchpad.net/~username/apt/test'])) |
5361.1.1
by John Arbash Meinel
Handle a simple ~ in lp: urls. |
381 |
self.assertIs(None, get_lp_login()) |
382 |
directory = LaunchpadDirectory() |
|
6729.6.1
by Jelmer Vernooij
Move urlutils errors. |
383 |
self.assertRaises(lp_registration.InvalidURL, |
5462.4.3
by Barry Warsaw
* Add back Ubuntu distroseries shortcuts. |
384 |
directory._resolve, 'lp:~/apt/test', factory) |
5361.1.1
by John Arbash Meinel
Handle a simple ~ in lp: urls. |
385 |
|
2898.4.17
by James Henstridge
Add a test that the redirect actually occurs when opening an lp: URL. |
386 |
|
3251.4.3
by Aaron Bentley
More renames and cleanups |
387 |
class DirectoryOpenBranchTests(TestCaseWithMemoryTransport): |
2898.4.17
by James Henstridge
Add a test that the redirect actually occurs when opening an lp: URL. |
388 |
|
3251.4.3
by Aaron Bentley
More renames and cleanups |
389 |
def test_directory_open_branch(self): |
2898.4.17
by James Henstridge
Add a test that the redirect actually occurs when opening an lp: URL. |
390 |
# Test that opening an lp: branch redirects to the real location.
|
391 |
target_branch = self.make_branch('target') |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
392 |
|
3251.4.1
by Aaron Bentley
Convert LP transport into directory service |
393 |
class FooService(object): |
394 |
"""A directory service that maps the name to a FILE url""" |
|
395 |
||
7268.11.2
by Jelmer Vernooij
Add purpose argument. |
396 |
def look_up(self, name, url, purpose=None): |
3251.4.1
by Aaron Bentley
Convert LP transport into directory service |
397 |
if 'lp:///apt' == url: |
398 |
return target_branch.base.rstrip('/') |
|
3251.4.2
by Aaron Bentley
Clean up Launchpad directory service code |
399 |
return '!unexpected look_up value!' |
3251.4.1
by Aaron Bentley
Convert LP transport into directory service |
400 |
|
401 |
directories.remove('lp:') |
|
7240.11.1
by Jelmer Vernooij
Add support for lp+bzr. |
402 |
directories.remove('lp+bzr:') |
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
403 |
directories.remove('ubuntu:') |
404 |
directories.remove('debianlp:') |
|
3251.4.1
by Aaron Bentley
Convert LP transport into directory service |
405 |
directories.register('lp:', FooService, 'Map lp URLs to local urls') |
3251.4.2
by Aaron Bentley
Clean up Launchpad directory service code |
406 |
self.addCleanup(_register_directory) |
4985.2.1
by Vincent Ladeuil
Deploy addAttrCleanup on the whole test suite. |
407 |
self.addCleanup(directories.remove, 'lp:') |
5273.1.7
by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through |
408 |
t = transport.get_transport('lp:///apt') |
409 |
branch = Branch.open_from_transport(t) |
|
2898.4.17
by James Henstridge
Add a test that the redirect actually occurs when opening an lp: URL. |
410 |
self.assertEqual(target_branch.base, branch.base) |
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
411 |
|
412 |
||
413 |
class PredefinedRequestHandler(http_server.TestingHTTPRequestHandler): |
|
414 |
"""Request handler for a unique and pre-defined request. |
|
415 |
||
416 |
The only thing we care about here is that we receive a connection. But
|
|
417 |
since we want to dialog with a real http client, we have to send it correct
|
|
418 |
responses.
|
|
419 |
||
420 |
We expect to receive a *single* request nothing more (and we won't even
|
|
421 |
check what request it is), the tests will recognize us from our response.
|
|
422 |
"""
|
|
423 |
||
424 |
def handle_one_request(self): |
|
425 |
tcs = self.server.test_case_server |
|
426 |
requestline = self.rfile.readline() |
|
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
427 |
parse_headers(self.rfile) |
7045.5.4
by Jelmer Vernooij
Fix a few more tests. |
428 |
if requestline.startswith(b'POST'): |
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
429 |
# The body should be a single line (or we don't know where it ends
|
430 |
# and we don't want to issue a blocking read)
|
|
5462.4.3
by Barry Warsaw
* Add back Ubuntu distroseries shortcuts. |
431 |
self.rfile.readline() |
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
432 |
|
433 |
self.wfile.write(tcs.canned_response) |
|
434 |
||
4776.2.6
by Vincent Ladeuil
Fixed as per review comments. |
435 |
|
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
436 |
class PreCannedServerMixin(object): |
437 |
||
438 |
def __init__(self): |
|
439 |
super(PreCannedServerMixin, self).__init__( |
|
440 |
request_handler=PredefinedRequestHandler) |
|
441 |
# Bytes read and written by the server
|
|
442 |
self.bytes_read = 0 |
|
443 |
self.bytes_written = 0 |
|
444 |
self.canned_response = None |
|
445 |
||
446 |
||
447 |
class PreCannedHTTPServer(PreCannedServerMixin, http_server.HttpServer): |
|
448 |
pass
|
|
449 |
||
450 |
||
5967.12.5
by Martin Pool
Update launchpad plugin for features under tests.features |
451 |
if features.HTTPSServerFeature.available(): |
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
452 |
from ...tests import https_server |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
453 |
|
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
454 |
class PreCannedHTTPSServer(PreCannedServerMixin, https_server.HTTPSServer): |
455 |
pass
|
|
456 |
||
457 |
||
4776.2.6
by Vincent Ladeuil
Fixed as per review comments. |
458 |
class TestXMLRPCTransport(tests.TestCase): |
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
459 |
|
460 |
# set by load_tests
|
|
461 |
server_class = None |
|
462 |
||
463 |
def setUp(self): |
|
6552.1.3
by Vincent Ladeuil
Use super() instead of calling <base>.setup(self), as the original fix illustrated a too-easy-to-fall-into trap. |
464 |
super(TestXMLRPCTransport, self).setUp() |
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
465 |
self.server = self.server_class() |
4934.3.3
by Martin Pool
Rename Server.setUp to Server.start_server |
466 |
self.server.start_server() |
6238.2.24
by Vincent Ladeuil
Fix the last test failure by providing the test ca certs via the config option framework. |
467 |
self.addCleanup(self.server.stop_server) |
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
468 |
# Ensure we don't clobber env
|
6622.1.28
by Jelmer Vernooij
More renames; commands in output, environment variables. |
469 |
self.overrideEnv('BRZ_LP_XMLRPC_URL', None) |
6238.2.24
by Vincent Ladeuil
Fix the last test failure by providing the test ca certs via the config option framework. |
470 |
# Ensure we use the right certificates for https.
|
471 |
# FIXME: There should be a better way but the only alternative I can
|
|
472 |
# think of involves carrying the ca_certs through the lp_registration
|
|
473 |
# infrastructure to _urllib2_wrappers... -- vila 2012-01-20
|
|
6759.4.2
by Jelmer Vernooij
Use get_global_state> |
474 |
breezy.get_global_state().cmdline_overrides._from_cmdline( |
6238.2.24
by Vincent Ladeuil
Fix the last test failure by providing the test ca certs via the config option framework. |
475 |
['ssl.ca_certs=%s' % ssl_certs.build_path('ca.crt')]) |
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
476 |
|
477 |
def set_canned_response(self, server, path): |
|
7045.5.6
by Jelmer Vernooij
Fix launchpad tests. |
478 |
response_format = b'''HTTP/1.1 200 OK\r |
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
479 |
Date: Tue, 11 Jul 2006 04:32:56 GMT\r |
480 |
Server: Apache/2.0.54 (Fedora)\r |
|
481 |
Last-Modified: Sun, 23 Apr 2006 19:35:20 GMT\r |
|
482 |
ETag: "56691-23-38e9ae00"\r |
|
483 |
Accept-Ranges: bytes\r |
|
484 |
Content-Length: %(length)d\r |
|
485 |
Connection: close\r |
|
486 |
Content-Type: text/plain; charset=UTF-8\r |
|
487 |
\r
|
|
488 |
<?xml version='1.0'?>
|
|
489 |
<methodResponse>
|
|
490 |
<params>
|
|
491 |
<param>
|
|
492 |
<value><struct>
|
|
493 |
<member>
|
|
494 |
<name>urls</name>
|
|
495 |
<value><array><data>
|
|
496 |
<value><string>bzr+ssh://bazaar.launchpad.net/%(path)s</string></value> |
|
497 |
<value><string>http://bazaar.launchpad.net/%(path)s</string></value> |
|
498 |
</data></array></value>
|
|
499 |
</member>
|
|
500 |
</struct></value>
|
|
501 |
</param>
|
|
502 |
</params>
|
|
503 |
</methodResponse>
|
|
504 |
'''
|
|
505 |
length = 334 + 2 * len(path) |
|
7045.5.6
by Jelmer Vernooij
Fix launchpad tests. |
506 |
server.canned_response = response_format % { |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
507 |
b'length': length, b'path': path} |
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
508 |
|
4776.2.3
by Vincent Ladeuil
Add NEWS entry. |
509 |
def do_request(self, server_url): |
6622.1.28
by Jelmer Vernooij
More renames; commands in output, environment variables. |
510 |
os.environ['BRZ_LP_XMLRPC_URL'] = self.server.get_url() |
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
511 |
service = lp_registration.LaunchpadService() |
512 |
resolve = lp_registration.ResolveLaunchpadPathRequest('bzr') |
|
513 |
result = resolve.submit(service) |
|
4776.2.3
by Vincent Ladeuil
Add NEWS entry. |
514 |
return result |
515 |
||
516 |
def test_direct_request(self): |
|
7045.5.6
by Jelmer Vernooij
Fix launchpad tests. |
517 |
self.set_canned_response(self.server, b'~bzr-pqm/bzr/bzr.dev') |
4776.2.3
by Vincent Ladeuil
Add NEWS entry. |
518 |
result = self.do_request(self.server.get_url()) |
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
519 |
urls = result.get('urls', None) |
520 |
self.assertIsNot(None, urls) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
521 |
self.assertEqual( |
4776.2.2
by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers. |
522 |
['bzr+ssh://bazaar.launchpad.net/~bzr-pqm/bzr/bzr.dev', |
523 |
'http://bazaar.launchpad.net/~bzr-pqm/bzr/bzr.dev'], |
|
524 |
urls) |
|
4776.2.3
by Vincent Ladeuil
Add NEWS entry. |
525 |
# FIXME: we need to test with a real proxy, I can't find a way so simulate
|
526 |
# CONNECT without leaving one server hanging the test :-/ Since that maybe
|
|
527 |
# related to the leaking tests problems, I'll punt for now -- vila 20091030
|
|
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
528 |
|
529 |
||
530 |
class TestDebuntuExpansions(TestCaseInTempDir): |
|
531 |
"""Test expansions for ubuntu: and debianlp: schemes.""" |
|
532 |
||
533 |
def setUp(self): |
|
5558.1.1
by Vincent Ladeuil
Catch the fugitive TestDebuntuExpansions tests and bring them back in the isolation jail |
534 |
super(TestDebuntuExpansions, self).setUp() |
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
535 |
self.directory = LaunchpadDirectory() |
536 |
||
537 |
def _make_factory(self, package='foo', distro='ubuntu', series=None): |
|
538 |
if series is None: |
|
539 |
path = '%s/%s' % (distro, package) |
|
540 |
url_suffix = '~branch/%s/%s' % (distro, package) |
|
541 |
else: |
|
542 |
path = '%s/%s/%s' % (distro, series, package) |
|
543 |
url_suffix = '~branch/%s/%s/%s' % (distro, series, package) |
|
544 |
return FakeResolveFactory( |
|
545 |
self, path, dict(urls=[ |
|
546 |
'http://bazaar.launchpad.net/' + url_suffix])) |
|
547 |
||
5462.4.6
by Vincent Ladeuil
Add helper to simplify tests |
548 |
def assertURL(self, expected_url, shortcut, package='foo', distro='ubuntu', |
549 |
series=None): |
|
550 |
factory = self._make_factory(package=package, distro=distro, |
|
551 |
series=series) |
|
552 |
self.assertEqual('http://bazaar.launchpad.net/~branch/' + expected_url, |
|
553 |
self.directory._resolve(shortcut, factory)) |
|
554 |
||
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
555 |
# Bogus distro.
|
556 |
||
557 |
def test_bogus_distro(self): |
|
6772.1.1
by Jelmer Vernooij
Stub out requests for three more Launchpad tests. |
558 |
factory = FakeResolveFactory(self, 'foo', dict(urls=[])) |
6729.6.1
by Jelmer Vernooij
Move urlutils errors. |
559 |
self.assertRaises(lp_registration.InvalidURL, |
6772.1.1
by Jelmer Vernooij
Stub out requests for three more Launchpad tests. |
560 |
self.directory._resolve, 'gentoo:foo', factory) |
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
561 |
|
562 |
def test_trick_bogus_distro_u(self): |
|
6772.1.1
by Jelmer Vernooij
Stub out requests for three more Launchpad tests. |
563 |
factory = FakeResolveFactory(self, 'foo', dict(urls=[])) |
6729.6.1
by Jelmer Vernooij
Move urlutils errors. |
564 |
self.assertRaises(lp_registration.InvalidURL, |
6772.1.1
by Jelmer Vernooij
Stub out requests for three more Launchpad tests. |
565 |
self.directory._resolve, 'utube:foo', factory) |
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
566 |
|
567 |
def test_trick_bogus_distro_d(self): |
|
6772.1.1
by Jelmer Vernooij
Stub out requests for three more Launchpad tests. |
568 |
factory = FakeResolveFactory(self, 'foo', dict(urls=[])) |
6729.6.1
by Jelmer Vernooij
Move urlutils errors. |
569 |
self.assertRaises(lp_registration.InvalidURL, |
6772.1.1
by Jelmer Vernooij
Stub out requests for three more Launchpad tests. |
570 |
self.directory._resolve, 'debuntu:foo', factory) |
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
571 |
|
5462.4.3
by Barry Warsaw
* Add back Ubuntu distroseries shortcuts. |
572 |
def test_missing_ubuntu_distroseries_without_project(self): |
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
573 |
# Launchpad does not hold source packages for Intrepid. Missing or
|
5462.4.3
by Barry Warsaw
* Add back Ubuntu distroseries shortcuts. |
574 |
# bogus distroseries with no project name is treated like a project.
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
575 |
self.assertURL('ubuntu/intrepid', 'ubuntu:intrepid', |
576 |
package='intrepid') |
|
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
577 |
|
5462.4.3
by Barry Warsaw
* Add back Ubuntu distroseries shortcuts. |
578 |
def test_missing_ubuntu_distroseries_with_project(self): |
579 |
# Launchpad does not hold source packages for Intrepid. Missing or
|
|
580 |
# bogus distroseries with a project name is treated like an unknown
|
|
581 |
# series (i.e. we keep it verbatim).
|
|
5462.4.6
by Vincent Ladeuil
Add helper to simplify tests |
582 |
self.assertURL('ubuntu/intrepid/foo', |
583 |
'ubuntu:intrepid/foo', series='intrepid') |
|
5462.4.3
by Barry Warsaw
* Add back Ubuntu distroseries shortcuts. |
584 |
|
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
585 |
def test_missing_debian_distroseries(self): |
586 |
# Launchpad does not hold source packages for unstable. Missing or
|
|
587 |
# bogus distroseries is treated like a project.
|
|
5462.4.6
by Vincent Ladeuil
Add helper to simplify tests |
588 |
self.assertURL('debian/sid', |
589 |
'debianlp:sid', package='sid', distro='debian') |
|
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
590 |
|
591 |
# Ubuntu Default distro series.
|
|
592 |
||
593 |
def test_ubuntu_default_distroseries_expansion(self): |
|
5462.4.6
by Vincent Ladeuil
Add helper to simplify tests |
594 |
self.assertURL('ubuntu/foo', 'ubuntu:foo') |
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
595 |
|
5462.4.2
by Barry Warsaw
Might as well support natty. |
596 |
def test_ubuntu_natty_distroseries_expansion(self): |
5462.4.6
by Vincent Ladeuil
Add helper to simplify tests |
597 |
self.assertURL('ubuntu/natty/foo', 'ubuntu:natty/foo', series='natty') |
5462.4.2
by Barry Warsaw
Might as well support natty. |
598 |
|
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
599 |
def test_ubuntu_maverick_distroseries_expansion(self): |
5462.4.6
by Vincent Ladeuil
Add helper to simplify tests |
600 |
self.assertURL('ubuntu/maverick/foo', 'ubuntu:maverick/foo', |
601 |
series='maverick') |
|
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
602 |
|
603 |
def test_ubuntu_lucid_distroseries_expansion(self): |
|
5462.4.6
by Vincent Ladeuil
Add helper to simplify tests |
604 |
self.assertURL('ubuntu/lucid/foo', 'ubuntu:lucid/foo', series='lucid') |
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
605 |
|
606 |
def test_ubuntu_karmic_distroseries_expansion(self): |
|
5462.4.6
by Vincent Ladeuil
Add helper to simplify tests |
607 |
self.assertURL('ubuntu/karmic/foo', 'ubuntu:karmic/foo', |
608 |
series='karmic') |
|
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
609 |
|
610 |
def test_ubuntu_jaunty_distroseries_expansion(self): |
|
5462.4.6
by Vincent Ladeuil
Add helper to simplify tests |
611 |
self.assertURL('ubuntu/jaunty/foo', 'ubuntu:jaunty/foo', |
612 |
series='jaunty') |
|
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
613 |
|
614 |
def test_ubuntu_hardy_distroseries_expansion(self): |
|
5462.4.6
by Vincent Ladeuil
Add helper to simplify tests |
615 |
self.assertURL('ubuntu/hardy/foo', 'ubuntu:hardy/foo', series='hardy') |
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
616 |
|
617 |
def test_ubuntu_dapper_distroseries_expansion(self): |
|
5462.4.6
by Vincent Ladeuil
Add helper to simplify tests |
618 |
self.assertURL('ubuntu/dapper/foo', 'ubuntu:dapper/foo', |
619 |
series='dapper') |
|
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
620 |
|
621 |
# Debian default distro series.
|
|
622 |
||
623 |
def test_debian_default_distroseries_expansion(self): |
|
5462.4.6
by Vincent Ladeuil
Add helper to simplify tests |
624 |
self.assertURL('debian/foo', 'debianlp:foo', distro='debian') |
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
625 |
|
626 |
def test_debian_squeeze_distroseries_expansion(self): |
|
5462.4.6
by Vincent Ladeuil
Add helper to simplify tests |
627 |
self.assertURL('debian/squeeze/foo', 'debianlp:squeeze/foo', |
628 |
distro='debian', series='squeeze') |
|
5462.4.1
by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant |
629 |
|
630 |
def test_debian_lenny_distroseries_expansion(self): |
|
5462.4.6
by Vincent Ladeuil
Add helper to simplify tests |
631 |
self.assertURL('debian/lenny/foo', 'debianlp:lenny/foo', |
632 |
distro='debian', series='lenny') |