77
77
def submit(self, service):
78
78
self._service_url = service.service_url
79
self._submitted = True
79
80
return self._result
83
class LocalDirectoryURLTests(TestCaseInTempDir):
84
"""Tests for branch urls that we try to pass through local resolution."""
86
def assertResolve(self, expected, url, submitted=False):
87
path = url[url.index(':')+1:].lstrip('/')
88
factory = FakeResolveFactory(self, path,
89
dict(urls=['bzr+ssh://fake-resolved']))
90
directory = LaunchpadDirectory()
91
self.assertEqual(expected,
92
directory._resolve(url, factory, _lp_login='user'))
93
# We are testing local resolution, and the fallback when necessary.
94
self.assertEqual(submitted, factory._submitted)
96
def test_short_form(self):
97
self.assertResolve('bzr+ssh://bazaar.launchpad.net/+branch/apt',
100
def test_two_part_form(self):
101
self.assertResolve('bzr+ssh://bazaar.launchpad.net/+branch/apt/2.2',
104
def test_two_part_plus_subdir(self):
105
# We allow you to pass more than just what resolves. That way you can
106
# do things like "bzr log lp:apt/2.2/BUGS"
107
# Though the virtual FS implementation currently aborts when given a
108
# URL like this, rather than letting you recurse upwards to find the
109
# real branch at lp:apt/2.2
110
self.assertResolve('bzr+ssh://bazaar.launchpad.net/+branch/apt/2.2/BUGS',
113
def test_user_expansion(self):
114
self.assertResolve('bzr+ssh://bazaar.launchpad.net/~user/apt/foo',
117
def test_ubuntu(self):
118
# Confirmed against xmlrpc. If you don't have a ~user, xmlrpc doesn't
119
# care that you are asking for 'ubuntu'
120
self.assertResolve('bzr+ssh://bazaar.launchpad.net/+branch/ubuntu',
123
def test_ubuntu_apt(self):
124
self.assertResolve('bzr+ssh://bazaar.launchpad.net/+branch/ubuntu/apt',
127
def test_ubuntu_natty_apt(self):
129
'bzr+ssh://bazaar.launchpad.net/+branch/ubuntu/natty/apt',
130
'lp:ubuntu/natty/apt')
132
def test_ubuntu_natty_apt_filename(self):
134
'bzr+ssh://bazaar.launchpad.net/+branch/ubuntu/natty/apt/filename',
135
'lp:ubuntu/natty/apt/filename')
137
def test_user_two_part(self):
138
# We fall back to the ResolveFactory. The real Launchpad one will raise
139
# InvalidURL for this case.
140
self.assertResolve('bzr+ssh://fake-resolved', 'lp:~jameinel/apt',
143
def test_user_three_part(self):
144
self.assertResolve('bzr+ssh://bazaar.launchpad.net/~jameinel/apt/foo',
145
'lp:~jameinel/apt/foo')
147
def test_user_three_part_plus_filename(self):
149
'bzr+ssh://bazaar.launchpad.net/~jameinel/apt/foo/fname',
150
'lp:~jameinel/apt/foo/fname')
152
def test_user_ubuntu_two_part(self):
153
self.assertResolve('bzr+ssh://fake-resolved', 'lp:~jameinel/ubuntu',
155
self.assertResolve('bzr+ssh://fake-resolved', 'lp:~jameinel/debian',
158
def test_user_ubuntu_three_part(self):
159
self.assertResolve('bzr+ssh://fake-resolved',
160
'lp:~jameinel/ubuntu/natty', submitted=True)
161
self.assertResolve('bzr+ssh://fake-resolved',
162
'lp:~jameinel/debian/sid', submitted=True)
164
def test_user_ubuntu_four_part(self):
165
self.assertResolve('bzr+ssh://fake-resolved',
166
'lp:~jameinel/ubuntu/natty/project', submitted=True)
167
self.assertResolve('bzr+ssh://fake-resolved',
168
'lp:~jameinel/debian/sid/project', submitted=True)
170
def test_user_ubuntu_five_part(self):
172
'bzr+ssh://bazaar.launchpad.net/~jameinel/ubuntu/natty/apt/branch',
173
'lp:~jameinel/ubuntu/natty/apt/branch')
175
'bzr+ssh://bazaar.launchpad.net/~jameinel/debian/sid/apt/branch',
176
'lp:~jameinel/debian/sid/apt/branch')
178
def test_user_ubuntu_five_part_plus_subdir(self):
180
'bzr+ssh://bazaar.launchpad.net/~jameinel/ubuntu/natty/apt/branch/f',
181
'lp:~jameinel/ubuntu/natty/apt/branch/f')
183
'bzr+ssh://bazaar.launchpad.net/~jameinel/debian/sid/apt/branch/f',
184
'lp:~jameinel/debian/sid/apt/branch/f')
186
def test_handles_special_lp(self):
187
self.assertResolve('bzr+ssh://bazaar.launchpad.net/+branch/apt', 'lp:apt')
188
self.assertResolve('bzr+ssh://bazaar.launchpad.net/+branch/apt',
190
self.assertResolve('bzr+ssh://bazaar.launchpad.net/+branch/apt',
191
'lp://production/apt')
192
self.assertResolve('bzr+ssh://bazaar.launchpad.dev/+branch/apt',
194
self.assertResolve('bzr+ssh://bazaar.staging.launchpad.net/+branch/apt',
196
self.assertResolve('bzr+ssh://bazaar.qastaging.launchpad.net/+branch/apt',
197
'lp://qastaging/apt')
198
self.assertResolve('bzr+ssh://bazaar.demo.launchpad.net/+branch/apt',
201
def test_debug_launchpad_uses_resolver(self):
202
self.assertResolve('bzr+ssh://bazaar.launchpad.net/+branch/bzr',
203
'lp:bzr', submitted=False)
204
debug.debug_flags.add('launchpad')
205
self.addCleanup(debug.debug_flags.discard, 'launchpad')
206
self.assertResolve('bzr+ssh://fake-resolved', 'lp:bzr', submitted=True)
82
209
class DirectoryUrlTests(TestCaseInTempDir):
83
210
"""Tests for branch urls through Launchpad.net directory"""
356
498
# FIXME: we need to test with a real proxy, I can't find a way so simulate
357
499
# CONNECT without leaving one server hanging the test :-/ Since that maybe
358
500
# related to the leaking tests problems, I'll punt for now -- vila 20091030
503
class TestDebuntuExpansions(TestCaseInTempDir):
504
"""Test expansions for ubuntu: and debianlp: schemes."""
507
super(TestDebuntuExpansions, self).setUp()
508
self.directory = LaunchpadDirectory()
510
def _make_factory(self, package='foo', distro='ubuntu', series=None):
512
path = '%s/%s' % (distro, package)
513
url_suffix = '~branch/%s/%s' % (distro, package)
515
path = '%s/%s/%s' % (distro, series, package)
516
url_suffix = '~branch/%s/%s/%s' % (distro, series, package)
517
return FakeResolveFactory(
518
self, path, dict(urls=[
519
'http://bazaar.launchpad.net/' + url_suffix]))
521
def assertURL(self, expected_url, shortcut, package='foo', distro='ubuntu',
523
factory = self._make_factory(package=package, distro=distro,
525
self.assertEqual('http://bazaar.launchpad.net/~branch/' + expected_url,
526
self.directory._resolve(shortcut, factory))
530
def test_bogus_distro(self):
531
self.assertRaises(errors.InvalidURL,
532
self.directory._resolve, 'gentoo:foo')
534
def test_trick_bogus_distro_u(self):
535
self.assertRaises(errors.InvalidURL,
536
self.directory._resolve, 'utube:foo')
538
def test_trick_bogus_distro_d(self):
539
self.assertRaises(errors.InvalidURL,
540
self.directory._resolve, 'debuntu:foo')
542
def test_missing_ubuntu_distroseries_without_project(self):
543
# Launchpad does not hold source packages for Intrepid. Missing or
544
# bogus distroseries with no project name is treated like a project.
545
self.assertURL('ubuntu/intrepid', 'ubuntu:intrepid', package='intrepid')
547
def test_missing_ubuntu_distroseries_with_project(self):
548
# Launchpad does not hold source packages for Intrepid. Missing or
549
# bogus distroseries with a project name is treated like an unknown
550
# series (i.e. we keep it verbatim).
551
self.assertURL('ubuntu/intrepid/foo',
552
'ubuntu:intrepid/foo', series='intrepid')
554
def test_missing_debian_distroseries(self):
555
# Launchpad does not hold source packages for unstable. Missing or
556
# bogus distroseries is treated like a project.
557
self.assertURL('debian/sid',
558
'debianlp:sid', package='sid', distro='debian')
560
# Ubuntu Default distro series.
562
def test_ubuntu_default_distroseries_expansion(self):
563
self.assertURL('ubuntu/foo', 'ubuntu:foo')
565
def test_ubuntu_natty_distroseries_expansion(self):
566
self.assertURL('ubuntu/natty/foo', 'ubuntu:natty/foo', series='natty')
568
def test_ubuntu_n_distroseries_expansion(self):
569
self.assertURL('ubuntu/natty/foo', 'ubuntu:n/foo', series='natty')
571
def test_ubuntu_maverick_distroseries_expansion(self):
572
self.assertURL('ubuntu/maverick/foo', 'ubuntu:maverick/foo',
575
def test_ubuntu_m_distroseries_expansion(self):
576
self.assertURL('ubuntu/maverick/foo', 'ubuntu:m/foo', series='maverick')
578
def test_ubuntu_lucid_distroseries_expansion(self):
579
self.assertURL('ubuntu/lucid/foo', 'ubuntu:lucid/foo', series='lucid')
581
def test_ubuntu_l_distroseries_expansion(self):
582
self.assertURL('ubuntu/lucid/foo', 'ubuntu:l/foo', series='lucid')
584
def test_ubuntu_karmic_distroseries_expansion(self):
585
self.assertURL('ubuntu/karmic/foo', 'ubuntu:karmic/foo',
588
def test_ubuntu_k_distroseries_expansion(self):
589
self.assertURL('ubuntu/karmic/foo', 'ubuntu:k/foo', series='karmic')
591
def test_ubuntu_jaunty_distroseries_expansion(self):
592
self.assertURL('ubuntu/jaunty/foo', 'ubuntu:jaunty/foo',
595
def test_ubuntu_j_distroseries_expansion(self):
596
self.assertURL('ubuntu/jaunty/foo', 'ubuntu:j/foo', series='jaunty')
598
def test_ubuntu_hardy_distroseries_expansion(self):
599
self.assertURL('ubuntu/hardy/foo', 'ubuntu:hardy/foo', series='hardy')
601
def test_ubuntu_h_distroseries_expansion(self):
602
self.assertURL('ubuntu/hardy/foo', 'ubuntu:h/foo', series='hardy')
604
def test_ubuntu_dapper_distroseries_expansion(self):
605
self.assertURL('ubuntu/dapper/foo', 'ubuntu:dapper/foo',
608
def test_ubuntu_d_distroseries_expansion(self):
609
self.assertURL('ubuntu/dapper/foo', 'ubuntu:d/foo', series='dapper')
611
# Debian default distro series.
613
def test_debian_default_distroseries_expansion(self):
614
self.assertURL('debian/foo', 'debianlp:foo', distro='debian')
616
def test_debian_squeeze_distroseries_expansion(self):
617
self.assertURL('debian/squeeze/foo', 'debianlp:squeeze/foo',
618
distro='debian', series='squeeze')
620
def test_debian_lenny_distroseries_expansion(self):
621
self.assertURL('debian/lenny/foo', 'debianlp:lenny/foo',
622
distro='debian', series='lenny')