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