/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:
7045.5.6 by Jelmer Vernooij
Fix launchpad tests.
22
    from xmlrpc.client import Fault
7045.5.4 by Jelmer Vernooij
Fix a few more tests.
23
    from http.client import parse_headers
6973.12.9 by Jelmer Vernooij
More fixes.
24
except ImportError:  # python < 3
7045.5.6 by Jelmer Vernooij
Fix launchpad tests.
25
    from xmlrpclib import Fault
2898.4.4 by James Henstridge
Changes to account for modifications to the XMLRPC API.
26
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
27
import breezy
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
28
from ... import (
5609.24.11 by John Arbash Meinel
If someone uses -Dlaunchpad, use the 'official' URL instead of the local one.
29
    debug,
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
7045.5.4 by Jelmer Vernooij
Fix a few more tests.
35
from ...sixish import PY3
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
36
from ...tests import (
5967.12.5 by Martin Pool
Update launchpad plugin for features under tests.features
37
    features,
6238.2.24 by Vincent Ladeuil
Fix the last test failure by providing the test ca certs via the config option framework.
38
    ssl_certs,
3777.1.18 by Aaron Bentley
Fix None handling wrt auth upgrades
39
    TestCaseInTempDir,
40
    TestCaseWithMemoryTransport
41
)
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
42
from . import (
4776.2.2 by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers.
43
    _register_directory,
44
    lp_registration,
45
    )
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
46
from .lp_directory import (
3251.4.1 by Aaron Bentley
Convert LP transport into directory service
47
    LaunchpadDirectory)
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
48
from .account import get_lp_login, set_lp_login
49
from ...tests import http_server
4776.2.2 by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers.
50
51
6625.1.5 by Martin
Drop custom load_tests implementation and use unittest signature
52
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.
53
    result = loader.suiteClass()
54
    t_tests, remaining_tests = tests.split_suite_by_condition(
55
        standard_tests, tests.condition_isinstance((
7143.15.2 by Jelmer Vernooij
Run autopep8.
56
            TestXMLRPCTransport,
57
            )))
4776.2.2 by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers.
58
    transport_scenarios = [
59
        ('http', dict(server_class=PreCannedHTTPServer,)),
60
        ]
5967.12.5 by Martin Pool
Update launchpad plugin for features under tests.features
61
    if features.HTTPSServerFeature.available():
4776.2.2 by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers.
62
        transport_scenarios.append(
63
            ('https', dict(server_class=PreCannedHTTPSServer,)),
64
            )
65
    tests.multiply_tests(t_tests, transport_scenarios, result)
66
67
    # No parametrization for the remaining tests
68
    result.addTests(remaining_tests)
69
70
    return result
2898.4.3 by James Henstridge
Make launchpad_transport_indirect() use XMLRPC to resolve the lp: URL.
71
72
73
class FakeResolveFactory(object):
5609.24.9 by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution.
74
2898.4.3 by James Henstridge
Make launchpad_transport_indirect() use XMLRPC to resolve the lp: URL.
75
    def __init__(self, test, expected_path, result):
76
        self._test = test
77
        self._expected_path = expected_path
78
        self._result = result
5609.24.9 by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution.
79
        self._submitted = False
2898.4.3 by James Henstridge
Make launchpad_transport_indirect() use XMLRPC to resolve the lp: URL.
80
81
    def __call__(self, path):
82
        self._test.assertEqual(self._expected_path, path)
83
        return self
84
85
    def submit(self, service):
3193.5.2 by Tim Penhey
Updated the tests to handle unknown launchpad instances.
86
        self._service_url = service.service_url
5609.24.9 by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution.
87
        self._submitted = True
2898.4.3 by James Henstridge
Make launchpad_transport_indirect() use XMLRPC to resolve the lp: URL.
88
        return self._result
2245.8.1 by Martin Pool
Start adding tests for launchpad indirection
89
2245.8.7 by Martin Pool
small review cleanups
90
5609.24.9 by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution.
91
class LocalDirectoryURLTests(TestCaseInTempDir):
92
    """Tests for branch urls that we try to pass through local resolution."""
93
94
    def assertResolve(self, expected, url, submitted=False):
7143.15.2 by Jelmer Vernooij
Run autopep8.
95
        path = url[url.index(':') + 1:].lstrip('/')
5609.24.9 by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution.
96
        factory = FakeResolveFactory(self, path,
7143.15.2 by Jelmer Vernooij
Run autopep8.
97
                                     dict(urls=['bzr+ssh://fake-resolved']))
5609.24.9 by John Arbash Meinel
A bunch more tests and bug fixes for the local resolution.
98
        directory = LaunchpadDirectory()
99
        self.assertEqual(expected,
7143.15.2 by Jelmer Vernooij
Run autopep8.
100
                         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.
101
        # We are testing local resolution, and the fallback when necessary.
102
        self.assertEqual(submitted, factory._submitted)
103
104
    def test_short_form(self):
105
        self.assertResolve('bzr+ssh://bazaar.launchpad.net/+branch/apt',
106
                           'lp:apt')
107
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')
212
        self.assertResolve('bzr+ssh://bazaar.launchpad.dev/+branch/apt',
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
396
            def look_up(self, name, url):
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:')
5462.4.1 by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant
402
        directories.remove('ubuntu:')
403
        directories.remove('debianlp:')
3251.4.1 by Aaron Bentley
Convert LP transport into directory service
404
        directories.register('lp:', FooService, 'Map lp URLs to local urls')
3251.4.2 by Aaron Bentley
Clean up Launchpad directory service code
405
        self.addCleanup(_register_directory)
4985.2.1 by Vincent Ladeuil
Deploy addAttrCleanup on the whole test suite.
406
        self.addCleanup(directories.remove, 'lp:')
5273.1.7 by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through
407
        t = transport.get_transport('lp:///apt')
408
        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.
409
        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.
410
411
412
class PredefinedRequestHandler(http_server.TestingHTTPRequestHandler):
413
    """Request handler for a unique and pre-defined request.
414
415
    The only thing we care about here is that we receive a connection. But
416
    since we want to dialog with a real http client, we have to send it correct
417
    responses.
418
419
    We expect to receive a *single* request nothing more (and we won't even
420
    check what request it is), the tests will recognize us from our response.
421
    """
422
423
    def handle_one_request(self):
424
        tcs = self.server.test_case_server
425
        requestline = self.rfile.readline()
7045.5.4 by Jelmer Vernooij
Fix a few more tests.
426
        if PY3:
427
            parse_headers(self.rfile)
428
        else:
429
            self.MessageClass(self.rfile, 0)
430
        if requestline.startswith(b'POST'):
4776.2.2 by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers.
431
            # The body should be a single line (or we don't know where it ends
432
            # and we don't want to issue a blocking read)
5462.4.3 by Barry Warsaw
* Add back Ubuntu distroseries shortcuts.
433
            self.rfile.readline()
4776.2.2 by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers.
434
435
        self.wfile.write(tcs.canned_response)
436
4776.2.6 by Vincent Ladeuil
Fixed as per review comments.
437
4776.2.2 by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers.
438
class PreCannedServerMixin(object):
439
440
    def __init__(self):
441
        super(PreCannedServerMixin, self).__init__(
442
            request_handler=PredefinedRequestHandler)
443
        # Bytes read and written by the server
444
        self.bytes_read = 0
445
        self.bytes_written = 0
446
        self.canned_response = None
447
448
449
class PreCannedHTTPServer(PreCannedServerMixin, http_server.HttpServer):
450
    pass
451
452
5967.12.5 by Martin Pool
Update launchpad plugin for features under tests.features
453
if features.HTTPSServerFeature.available():
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
454
    from ...tests import https_server
7143.15.2 by Jelmer Vernooij
Run autopep8.
455
4776.2.2 by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers.
456
    class PreCannedHTTPSServer(PreCannedServerMixin, https_server.HTTPSServer):
457
        pass
458
459
4776.2.6 by Vincent Ladeuil
Fixed as per review comments.
460
class TestXMLRPCTransport(tests.TestCase):
4776.2.2 by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers.
461
462
    # set by load_tests
463
    server_class = None
464
465
    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.
466
        super(TestXMLRPCTransport, self).setUp()
4776.2.2 by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers.
467
        self.server = self.server_class()
4934.3.3 by Martin Pool
Rename Server.setUp to Server.start_server
468
        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.
469
        self.addCleanup(self.server.stop_server)
4776.2.2 by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers.
470
        # Ensure we don't clobber env
6622.1.28 by Jelmer Vernooij
More renames; commands in output, environment variables.
471
        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.
472
        # Ensure we use the right certificates for https.
473
        # FIXME: There should be a better way but the only alternative I can
474
        # think of involves carrying the ca_certs through the lp_registration
475
        # infrastructure to _urllib2_wrappers... -- vila 2012-01-20
6759.4.2 by Jelmer Vernooij
Use get_global_state>
476
        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.
477
            ['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.
478
479
    def set_canned_response(self, server, path):
7045.5.6 by Jelmer Vernooij
Fix launchpad tests.
480
        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.
481
Date: Tue, 11 Jul 2006 04:32:56 GMT\r
482
Server: Apache/2.0.54 (Fedora)\r
483
Last-Modified: Sun, 23 Apr 2006 19:35:20 GMT\r
484
ETag: "56691-23-38e9ae00"\r
485
Accept-Ranges: bytes\r
486
Content-Length: %(length)d\r
487
Connection: close\r
488
Content-Type: text/plain; charset=UTF-8\r
489
\r
490
<?xml version='1.0'?>
491
<methodResponse>
492
<params>
493
<param>
494
<value><struct>
495
<member>
496
<name>urls</name>
497
<value><array><data>
498
<value><string>bzr+ssh://bazaar.launchpad.net/%(path)s</string></value>
499
<value><string>http://bazaar.launchpad.net/%(path)s</string></value>
500
</data></array></value>
501
</member>
502
</struct></value>
503
</param>
504
</params>
505
</methodResponse>
506
'''
507
        length = 334 + 2 * len(path)
7045.5.6 by Jelmer Vernooij
Fix launchpad tests.
508
        server.canned_response = response_format % {
7143.15.2 by Jelmer Vernooij
Run autopep8.
509
            b'length': length, b'path': path}
4776.2.2 by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers.
510
4776.2.3 by Vincent Ladeuil
Add NEWS entry.
511
    def do_request(self, server_url):
6622.1.28 by Jelmer Vernooij
More renames; commands in output, environment variables.
512
        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.
513
        service = lp_registration.LaunchpadService()
514
        resolve = lp_registration.ResolveLaunchpadPathRequest('bzr')
515
        result = resolve.submit(service)
4776.2.3 by Vincent Ladeuil
Add NEWS entry.
516
        return result
517
518
    def test_direct_request(self):
7045.5.6 by Jelmer Vernooij
Fix launchpad tests.
519
        self.set_canned_response(self.server, b'~bzr-pqm/bzr/bzr.dev')
4776.2.3 by Vincent Ladeuil
Add NEWS entry.
520
        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.
521
        urls = result.get('urls', None)
522
        self.assertIsNot(None, urls)
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
523
        self.assertEqual(
4776.2.2 by Vincent Ladeuil
Start testing the XMLRPC transport re-implemented on top of _urllib2_wrappers.
524
            ['bzr+ssh://bazaar.launchpad.net/~bzr-pqm/bzr/bzr.dev',
525
             'http://bazaar.launchpad.net/~bzr-pqm/bzr/bzr.dev'],
526
            urls)
4776.2.3 by Vincent Ladeuil
Add NEWS entry.
527
    # FIXME: we need to test with a real proxy, I can't find a way so simulate
528
    # CONNECT without leaving one server hanging the test :-/ Since that maybe
529
    # 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
530
531
532
class TestDebuntuExpansions(TestCaseInTempDir):
533
    """Test expansions for ubuntu: and debianlp: schemes."""
534
535
    def setUp(self):
5558.1.1 by Vincent Ladeuil
Catch the fugitive TestDebuntuExpansions tests and bring them back in the isolation jail
536
        super(TestDebuntuExpansions, self).setUp()
5462.4.1 by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant
537
        self.directory = LaunchpadDirectory()
538
539
    def _make_factory(self, package='foo', distro='ubuntu', series=None):
540
        if series is None:
541
            path = '%s/%s' % (distro, package)
542
            url_suffix = '~branch/%s/%s' % (distro, package)
543
        else:
544
            path = '%s/%s/%s' % (distro, series, package)
545
            url_suffix = '~branch/%s/%s/%s' % (distro, series, package)
546
        return FakeResolveFactory(
547
            self, path, dict(urls=[
548
                'http://bazaar.launchpad.net/' + url_suffix]))
549
5462.4.6 by Vincent Ladeuil
Add helper to simplify tests
550
    def assertURL(self, expected_url, shortcut, package='foo', distro='ubuntu',
551
                  series=None):
552
        factory = self._make_factory(package=package, distro=distro,
553
                                     series=series)
554
        self.assertEqual('http://bazaar.launchpad.net/~branch/' + expected_url,
555
                         self.directory._resolve(shortcut, factory))
556
5462.4.1 by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant
557
    # Bogus distro.
558
559
    def test_bogus_distro(self):
6772.1.1 by Jelmer Vernooij
Stub out requests for three more Launchpad tests.
560
        factory = FakeResolveFactory(self, 'foo', dict(urls=[]))
6729.6.1 by Jelmer Vernooij
Move urlutils errors.
561
        self.assertRaises(lp_registration.InvalidURL,
6772.1.1 by Jelmer Vernooij
Stub out requests for three more Launchpad tests.
562
                          self.directory._resolve, 'gentoo:foo', factory)
5462.4.1 by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant
563
564
    def test_trick_bogus_distro_u(self):
6772.1.1 by Jelmer Vernooij
Stub out requests for three more Launchpad tests.
565
        factory = FakeResolveFactory(self, 'foo', dict(urls=[]))
6729.6.1 by Jelmer Vernooij
Move urlutils errors.
566
        self.assertRaises(lp_registration.InvalidURL,
6772.1.1 by Jelmer Vernooij
Stub out requests for three more Launchpad tests.
567
                          self.directory._resolve, 'utube:foo', factory)
5462.4.1 by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant
568
569
    def test_trick_bogus_distro_d(self):
6772.1.1 by Jelmer Vernooij
Stub out requests for three more Launchpad tests.
570
        factory = FakeResolveFactory(self, 'foo', dict(urls=[]))
6729.6.1 by Jelmer Vernooij
Move urlutils errors.
571
        self.assertRaises(lp_registration.InvalidURL,
6772.1.1 by Jelmer Vernooij
Stub out requests for three more Launchpad tests.
572
                          self.directory._resolve, 'debuntu:foo', factory)
5462.4.1 by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant
573
5462.4.3 by Barry Warsaw
* Add back Ubuntu distroseries shortcuts.
574
    def test_missing_ubuntu_distroseries_without_project(self):
5462.4.1 by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant
575
        # Launchpad does not hold source packages for Intrepid.  Missing or
5462.4.3 by Barry Warsaw
* Add back Ubuntu distroseries shortcuts.
576
        # bogus distroseries with no project name is treated like a project.
7143.15.2 by Jelmer Vernooij
Run autopep8.
577
        self.assertURL('ubuntu/intrepid', 'ubuntu:intrepid',
578
                       package='intrepid')
5462.4.1 by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant
579
5462.4.3 by Barry Warsaw
* Add back Ubuntu distroseries shortcuts.
580
    def test_missing_ubuntu_distroseries_with_project(self):
581
        # Launchpad does not hold source packages for Intrepid.  Missing or
582
        # bogus distroseries with a project name is treated like an unknown
583
        # series (i.e. we keep it verbatim).
5462.4.6 by Vincent Ladeuil
Add helper to simplify tests
584
        self.assertURL('ubuntu/intrepid/foo',
585
                       'ubuntu:intrepid/foo', series='intrepid')
5462.4.3 by Barry Warsaw
* Add back Ubuntu distroseries shortcuts.
586
5462.4.1 by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant
587
    def test_missing_debian_distroseries(self):
588
        # Launchpad does not hold source packages for unstable.  Missing or
589
        # bogus distroseries is treated like a project.
5462.4.6 by Vincent Ladeuil
Add helper to simplify tests
590
        self.assertURL('debian/sid',
591
                       'debianlp:sid', package='sid', distro='debian')
5462.4.1 by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant
592
593
    # Ubuntu Default distro series.
594
595
    def test_ubuntu_default_distroseries_expansion(self):
5462.4.6 by Vincent Ladeuil
Add helper to simplify tests
596
        self.assertURL('ubuntu/foo', 'ubuntu:foo')
5462.4.1 by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant
597
5462.4.2 by Barry Warsaw
Might as well support natty.
598
    def test_ubuntu_natty_distroseries_expansion(self):
5462.4.6 by Vincent Ladeuil
Add helper to simplify tests
599
        self.assertURL('ubuntu/natty/foo', 'ubuntu:natty/foo', series='natty')
5462.4.2 by Barry Warsaw
Might as well support natty.
600
5462.4.1 by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant
601
    def test_ubuntu_maverick_distroseries_expansion(self):
5462.4.6 by Vincent Ladeuil
Add helper to simplify tests
602
        self.assertURL('ubuntu/maverick/foo', 'ubuntu:maverick/foo',
603
                       series='maverick')
5462.4.1 by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant
604
605
    def test_ubuntu_lucid_distroseries_expansion(self):
5462.4.6 by Vincent Ladeuil
Add helper to simplify tests
606
        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
607
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
612
    def test_ubuntu_jaunty_distroseries_expansion(self):
5462.4.6 by Vincent Ladeuil
Add helper to simplify tests
613
        self.assertURL('ubuntu/jaunty/foo', 'ubuntu:jaunty/foo',
614
                       series='jaunty')
5462.4.1 by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant
615
616
    def test_ubuntu_hardy_distroseries_expansion(self):
5462.4.6 by Vincent Ladeuil
Add helper to simplify tests
617
        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
618
619
    def test_ubuntu_dapper_distroseries_expansion(self):
5462.4.6 by Vincent Ladeuil
Add helper to simplify tests
620
        self.assertURL('ubuntu/dapper/foo', 'ubuntu:dapper/foo',
621
                       series='dapper')
5462.4.1 by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant
622
623
    # Debian default distro series.
624
625
    def test_debian_default_distroseries_expansion(self):
5462.4.6 by Vincent Ladeuil
Add helper to simplify tests
626
        self.assertURL('debian/foo', 'debianlp:foo', distro='debian')
5462.4.1 by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant
627
628
    def test_debian_squeeze_distroseries_expansion(self):
5462.4.6 by Vincent Ladeuil
Add helper to simplify tests
629
        self.assertURL('debian/squeeze/foo', 'debianlp:squeeze/foo',
630
                       distro='debian', series='squeeze')
5462.4.1 by Barry Warsaw
Added support for ubuntu: and debianlp: schemes, accessing the relevant
631
632
    def test_debian_lenny_distroseries_expansion(self):
5462.4.6 by Vincent Ladeuil
Add helper to simplify tests
633
        self.assertURL('debian/lenny/foo', 'debianlp:lenny/foo',
634
                       distro='debian', series='lenny')