199
209
self.assertRaises(errors.InvalidURL,
200
210
directory._resolve, 'lp://ratotehunoahu')
212
def test_resolve_tilde_to_user(self):
213
factory = FakeResolveFactory(
214
self, '~username/apt/test', dict(urls=[
215
'bzr+ssh://bazaar.launchpad.net/~username/apt/test']))
216
directory = LaunchpadDirectory()
218
'bzr+ssh://bazaar.launchpad.net/~username/apt/test',
219
directory._resolve('lp:~/apt/test', factory, _lp_login='username'))
220
# Should also happen when the login is just set by config
221
set_lp_login('username')
223
'bzr+ssh://bazaar.launchpad.net/~username/apt/test',
224
directory._resolve('lp:~/apt/test', factory))
226
def test_tilde_fails_no_login(self):
227
factory = FakeResolveFactory(
228
self, '~username/apt/test', dict(urls=[
229
'bzr+ssh://bazaar.launchpad.net/~username/apt/test']))
230
self.assertIs(None, get_lp_login())
231
directory = LaunchpadDirectory()
232
self.assertRaises(errors.InvalidURL,
233
directory._resolve, 'lp:~/apt/test', factory)
203
236
class DirectoryOpenBranchTests(TestCaseWithMemoryTransport):
333
368
# FIXME: we need to test with a real proxy, I can't find a way so simulate
334
369
# CONNECT without leaving one server hanging the test :-/ Since that maybe
335
370
# related to the leaking tests problems, I'll punt for now -- vila 20091030
373
class TestDebuntuExpansions(TestCaseInTempDir):
374
"""Test expansions for ubuntu: and debianlp: schemes."""
377
super(TestDebuntuExpansions, self).setUp()
378
self.directory = LaunchpadDirectory()
380
def _make_factory(self, package='foo', distro='ubuntu', series=None):
382
path = '%s/%s' % (distro, package)
383
url_suffix = '~branch/%s/%s' % (distro, package)
385
path = '%s/%s/%s' % (distro, series, package)
386
url_suffix = '~branch/%s/%s/%s' % (distro, series, package)
387
return FakeResolveFactory(
388
self, path, dict(urls=[
389
'http://bazaar.launchpad.net/' + url_suffix]))
391
def assertURL(self, expected_url, shortcut, package='foo', distro='ubuntu',
393
factory = self._make_factory(package=package, distro=distro,
395
self.assertEqual('http://bazaar.launchpad.net/~branch/' + expected_url,
396
self.directory._resolve(shortcut, factory))
400
def test_bogus_distro(self):
401
self.assertRaises(errors.InvalidURL,
402
self.directory._resolve, 'gentoo:foo')
404
def test_trick_bogus_distro_u(self):
405
self.assertRaises(errors.InvalidURL,
406
self.directory._resolve, 'utube:foo')
408
def test_trick_bogus_distro_d(self):
409
self.assertRaises(errors.InvalidURL,
410
self.directory._resolve, 'debuntu:foo')
412
def test_missing_ubuntu_distroseries_without_project(self):
413
# Launchpad does not hold source packages for Intrepid. Missing or
414
# bogus distroseries with no project name is treated like a project.
415
self.assertURL('ubuntu/intrepid', 'ubuntu:intrepid', package='intrepid')
417
def test_missing_ubuntu_distroseries_with_project(self):
418
# Launchpad does not hold source packages for Intrepid. Missing or
419
# bogus distroseries with a project name is treated like an unknown
420
# series (i.e. we keep it verbatim).
421
self.assertURL('ubuntu/intrepid/foo',
422
'ubuntu:intrepid/foo', series='intrepid')
424
def test_missing_debian_distroseries(self):
425
# Launchpad does not hold source packages for unstable. Missing or
426
# bogus distroseries is treated like a project.
427
self.assertURL('debian/sid',
428
'debianlp:sid', package='sid', distro='debian')
430
# Ubuntu Default distro series.
432
def test_ubuntu_default_distroseries_expansion(self):
433
self.assertURL('ubuntu/foo', 'ubuntu:foo')
435
def test_ubuntu_natty_distroseries_expansion(self):
436
self.assertURL('ubuntu/natty/foo', 'ubuntu:natty/foo', series='natty')
438
def test_ubuntu_n_distroseries_expansion(self):
439
self.assertURL('ubuntu/natty/foo', 'ubuntu:n/foo', series='natty')
441
def test_ubuntu_maverick_distroseries_expansion(self):
442
self.assertURL('ubuntu/maverick/foo', 'ubuntu:maverick/foo',
445
def test_ubuntu_m_distroseries_expansion(self):
446
self.assertURL('ubuntu/maverick/foo', 'ubuntu:m/foo', series='maverick')
448
def test_ubuntu_lucid_distroseries_expansion(self):
449
self.assertURL('ubuntu/lucid/foo', 'ubuntu:lucid/foo', series='lucid')
451
def test_ubuntu_l_distroseries_expansion(self):
452
self.assertURL('ubuntu/lucid/foo', 'ubuntu:l/foo', series='lucid')
454
def test_ubuntu_karmic_distroseries_expansion(self):
455
self.assertURL('ubuntu/karmic/foo', 'ubuntu:karmic/foo',
458
def test_ubuntu_k_distroseries_expansion(self):
459
self.assertURL('ubuntu/karmic/foo', 'ubuntu:k/foo', series='karmic')
461
def test_ubuntu_jaunty_distroseries_expansion(self):
462
self.assertURL('ubuntu/jaunty/foo', 'ubuntu:jaunty/foo',
465
def test_ubuntu_j_distroseries_expansion(self):
466
self.assertURL('ubuntu/jaunty/foo', 'ubuntu:j/foo', series='jaunty')
468
def test_ubuntu_hardy_distroseries_expansion(self):
469
self.assertURL('ubuntu/hardy/foo', 'ubuntu:hardy/foo', series='hardy')
471
def test_ubuntu_h_distroseries_expansion(self):
472
self.assertURL('ubuntu/hardy/foo', 'ubuntu:h/foo', series='hardy')
474
def test_ubuntu_dapper_distroseries_expansion(self):
475
self.assertURL('ubuntu/dapper/foo', 'ubuntu:dapper/foo',
478
def test_ubuntu_d_distroseries_expansion(self):
479
self.assertURL('ubuntu/dapper/foo', 'ubuntu:d/foo', series='dapper')
481
# Debian default distro series.
483
def test_debian_default_distroseries_expansion(self):
484
self.assertURL('debian/foo', 'debianlp:foo', distro='debian')
486
def test_debian_squeeze_distroseries_expansion(self):
487
self.assertURL('debian/squeeze/foo', 'debianlp:squeeze/foo',
488
distro='debian', series='squeeze')
490
def test_debian_lenny_distroseries_expansion(self):
491
self.assertURL('debian/lenny/foo', 'debianlp:lenny/foo',
492
distro='debian', series='lenny')