~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugins/launchpad/test_lp_directory.py

Merge bzr.dev to resolve news conflict

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
from bzrlib.plugins.launchpad.lp_directory import (
38
38
    LaunchpadDirectory)
39
39
from bzrlib.plugins.launchpad.account import get_lp_login, set_lp_login
40
 
from bzrlib.tests import (
41
 
    http_server,
42
 
    http_utils,
43
 
    )
 
40
from bzrlib.tests import http_server
44
41
 
45
42
 
46
43
def load_tests(standard_tests, module, loader):
219
216
                    'bzr+ssh://bazaar.launchpad.net/~username/apt/test']))
220
217
        self.assertIs(None, get_lp_login())
221
218
        directory = LaunchpadDirectory()
222
 
        e = self.assertRaises(errors.InvalidURL,
223
 
            directory._resolve, 'lp:~/apt/test', factory)
 
219
        self.assertRaises(errors.InvalidURL,
 
220
                          directory._resolve, 'lp:~/apt/test', factory)
224
221
 
225
222
 
226
223
class DirectoryOpenBranchTests(TestCaseWithMemoryTransport):
237
234
                return '!unexpected look_up value!'
238
235
 
239
236
        directories.remove('lp:')
 
237
        directories.remove('ubuntu:')
 
238
        directories.remove('debianlp:')
240
239
        directories.register('lp:', FooService, 'Map lp URLs to local urls')
241
240
        self.addCleanup(_register_directory)
242
241
        self.addCleanup(directories.remove, 'lp:')
259
258
    def handle_one_request(self):
260
259
        tcs = self.server.test_case_server
261
260
        requestline = self.rfile.readline()
262
 
        headers = self.MessageClass(self.rfile, 0)
 
261
        self.MessageClass(self.rfile, 0)
263
262
        if requestline.startswith('POST'):
264
263
            # The body should be a single line (or we don't know where it ends
265
264
            # and we don't want to issue a blocking read)
266
 
            body = self.rfile.readline()
 
265
            self.rfile.readline()
267
266
 
268
267
        self.wfile.write(tcs.canned_response)
269
268
 
356
355
    # FIXME: we need to test with a real proxy, I can't find a way so simulate
357
356
    # CONNECT without leaving one server hanging the test :-/ Since that maybe
358
357
    # related to the leaking tests problems, I'll punt for now -- vila 20091030
 
358
 
 
359
 
 
360
class TestDebuntuExpansions(TestCaseInTempDir):
 
361
    """Test expansions for ubuntu: and debianlp: schemes."""
 
362
 
 
363
    def setUp(self):
 
364
        tests.TestCase.setUp(self)
 
365
        self.directory = LaunchpadDirectory()
 
366
 
 
367
    def _make_factory(self, package='foo', distro='ubuntu', series=None):
 
368
        if series is None:
 
369
            path = '%s/%s' % (distro, package)
 
370
            url_suffix = '~branch/%s/%s' % (distro, package)
 
371
        else:
 
372
            path = '%s/%s/%s' % (distro, series, package)
 
373
            url_suffix = '~branch/%s/%s/%s' % (distro, series, package)
 
374
        return FakeResolveFactory(
 
375
            self, path, dict(urls=[
 
376
                'http://bazaar.launchpad.net/' + url_suffix]))
 
377
 
 
378
    def assertURL(self, expected_url, shortcut, package='foo', distro='ubuntu',
 
379
                  series=None):
 
380
        factory = self._make_factory(package=package, distro=distro,
 
381
                                     series=series)
 
382
        self.assertEqual('http://bazaar.launchpad.net/~branch/' + expected_url,
 
383
                         self.directory._resolve(shortcut, factory))
 
384
 
 
385
    # Bogus distro.
 
386
 
 
387
    def test_bogus_distro(self):
 
388
        self.assertRaises(errors.InvalidURL,
 
389
                          self.directory._resolve, 'gentoo:foo')
 
390
 
 
391
    def test_trick_bogus_distro_u(self):
 
392
        self.assertRaises(errors.InvalidURL,
 
393
                          self.directory._resolve, 'utube:foo')
 
394
 
 
395
    def test_trick_bogus_distro_d(self):
 
396
        self.assertRaises(errors.InvalidURL,
 
397
                          self.directory._resolve, 'debuntu:foo')
 
398
 
 
399
    def test_missing_ubuntu_distroseries_without_project(self):
 
400
        # Launchpad does not hold source packages for Intrepid.  Missing or
 
401
        # bogus distroseries with no project name is treated like a project.
 
402
        self.assertURL('ubuntu/intrepid', 'ubuntu:intrepid', package='intrepid')
 
403
 
 
404
    def test_missing_ubuntu_distroseries_with_project(self):
 
405
        # Launchpad does not hold source packages for Intrepid.  Missing or
 
406
        # bogus distroseries with a project name is treated like an unknown
 
407
        # series (i.e. we keep it verbatim).
 
408
        self.assertURL('ubuntu/intrepid/foo',
 
409
                       'ubuntu:intrepid/foo', series='intrepid')
 
410
 
 
411
    def test_missing_debian_distroseries(self):
 
412
        # Launchpad does not hold source packages for unstable.  Missing or
 
413
        # bogus distroseries is treated like a project.
 
414
        self.assertURL('debian/sid',
 
415
                       'debianlp:sid', package='sid', distro='debian')
 
416
 
 
417
    # Ubuntu Default distro series.
 
418
 
 
419
    def test_ubuntu_default_distroseries_expansion(self):
 
420
        self.assertURL('ubuntu/foo', 'ubuntu:foo')
 
421
 
 
422
    def test_ubuntu_natty_distroseries_expansion(self):
 
423
        self.assertURL('ubuntu/natty/foo', 'ubuntu:natty/foo', series='natty')
 
424
 
 
425
    def test_ubuntu_n_distroseries_expansion(self):
 
426
        self.assertURL('ubuntu/natty/foo', 'ubuntu:n/foo', series='natty')
 
427
 
 
428
    def test_ubuntu_maverick_distroseries_expansion(self):
 
429
        self.assertURL('ubuntu/maverick/foo', 'ubuntu:maverick/foo',
 
430
                       series='maverick')
 
431
 
 
432
    def test_ubuntu_m_distroseries_expansion(self):
 
433
        self.assertURL('ubuntu/maverick/foo', 'ubuntu:m/foo', series='maverick')
 
434
 
 
435
    def test_ubuntu_lucid_distroseries_expansion(self):
 
436
        self.assertURL('ubuntu/lucid/foo', 'ubuntu:lucid/foo', series='lucid')
 
437
 
 
438
    def test_ubuntu_l_distroseries_expansion(self):
 
439
        self.assertURL('ubuntu/lucid/foo', 'ubuntu:l/foo', series='lucid')
 
440
 
 
441
    def test_ubuntu_karmic_distroseries_expansion(self):
 
442
        self.assertURL('ubuntu/karmic/foo', 'ubuntu:karmic/foo',
 
443
                       series='karmic')
 
444
 
 
445
    def test_ubuntu_k_distroseries_expansion(self):
 
446
        self.assertURL('ubuntu/karmic/foo', 'ubuntu:k/foo', series='karmic')
 
447
 
 
448
    def test_ubuntu_jaunty_distroseries_expansion(self):
 
449
        self.assertURL('ubuntu/jaunty/foo', 'ubuntu:jaunty/foo',
 
450
                       series='jaunty')
 
451
 
 
452
    def test_ubuntu_j_distroseries_expansion(self):
 
453
        self.assertURL('ubuntu/jaunty/foo', 'ubuntu:j/foo', series='jaunty')
 
454
 
 
455
    def test_ubuntu_hardy_distroseries_expansion(self):
 
456
        self.assertURL('ubuntu/hardy/foo', 'ubuntu:hardy/foo', series='hardy')
 
457
 
 
458
    def test_ubuntu_h_distroseries_expansion(self):
 
459
        self.assertURL('ubuntu/hardy/foo', 'ubuntu:h/foo', series='hardy')
 
460
 
 
461
    def test_ubuntu_dapper_distroseries_expansion(self):
 
462
        self.assertURL('ubuntu/dapper/foo', 'ubuntu:dapper/foo',
 
463
                       series='dapper')
 
464
 
 
465
    def test_ubuntu_d_distroseries_expansion(self):
 
466
        self.assertURL('ubuntu/dapper/foo', 'ubuntu:d/foo', series='dapper')
 
467
 
 
468
    # Debian default distro series.
 
469
 
 
470
    def test_debian_default_distroseries_expansion(self):
 
471
        self.assertURL('debian/foo', 'debianlp:foo', distro='debian')
 
472
 
 
473
    def test_debian_squeeze_distroseries_expansion(self):
 
474
        self.assertURL('debian/squeeze/foo', 'debianlp:squeeze/foo',
 
475
                       distro='debian', series='squeeze')
 
476
 
 
477
    def test_debian_lenny_distroseries_expansion(self):
 
478
        self.assertURL('debian/lenny/foo', 'debianlp:lenny/foo',
 
479
                       distro='debian', series='lenny')