/brz/remove-bazaar

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