~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2012-03-13 17:25:29 UTC
  • mfrom: (6499 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6501.
  • Revision ID: v.ladeuil+lp@free.fr-20120313172529-i0suyjnepsor25i7
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import os
20
20
import xmlrpclib
21
21
 
 
22
import bzrlib
22
23
from bzrlib import (
23
24
    debug,
24
25
    errors,
28
29
from bzrlib.branch import Branch
29
30
from bzrlib.directory_service import directories
30
31
from bzrlib.tests import (
 
32
    features,
 
33
    ssl_certs,
31
34
    TestCaseInTempDir,
32
35
    TestCaseWithMemoryTransport
33
36
)
50
53
    transport_scenarios = [
51
54
        ('http', dict(server_class=PreCannedHTTPServer,)),
52
55
        ]
53
 
    if tests.HTTPSServerFeature.available():
 
56
    if features.HTTPSServerFeature.available():
54
57
        transport_scenarios.append(
55
58
            ('https', dict(server_class=PreCannedHTTPSServer,)),
56
59
            )
120
123
        self.assertResolve('bzr+ssh://bazaar.launchpad.net/+branch/ubuntu',
121
124
                           'lp:ubuntu')
122
125
 
 
126
    def test_ubuntu_invalid(self):
 
127
        """Invalid ubuntu urls don't crash.
 
128
 
 
129
        :seealso: http://pad.lv/843900
 
130
        """
 
131
        # This ought to be natty-updates.
 
132
        self.assertRaises(errors.InvalidURL,
 
133
            self.assertResolve,
 
134
            '',
 
135
            'ubuntu:natty/updates/smartpm')
 
136
 
123
137
    def test_ubuntu_apt(self):
124
138
        self.assertResolve('bzr+ssh://bazaar.launchpad.net/+branch/ubuntu/apt',
125
139
                           'lp:ubuntu/apt')
425
439
    pass
426
440
 
427
441
 
428
 
if tests.HTTPSServerFeature.available():
 
442
if features.HTTPSServerFeature.available():
429
443
    from bzrlib.tests import https_server
430
444
    class PreCannedHTTPSServer(PreCannedServerMixin, https_server.HTTPSServer):
431
445
        pass
440
454
        tests.TestCase.setUp(self)
441
455
        self.server = self.server_class()
442
456
        self.server.start_server()
 
457
        self.addCleanup(self.server.stop_server)
443
458
        # Ensure we don't clobber env
444
459
        self.overrideEnv('BZR_LP_XMLRPC_URL', None)
445
 
 
446
 
    def tearDown(self):
447
 
        self.server.stop_server()
448
 
        tests.TestCase.tearDown(self)
 
460
        # Ensure we use the right certificates for https.
 
461
        # FIXME: There should be a better way but the only alternative I can
 
462
        # think of involves carrying the ca_certs through the lp_registration
 
463
        # infrastructure to _urllib2_wrappers... -- vila 2012-01-20
 
464
        bzrlib.global_state.cmdline_overrides._from_cmdline(
 
465
            ['ssl.ca_certs=%s' % ssl_certs.build_path('ca.crt')])
449
466
 
450
467
    def set_canned_response(self, server, path):
451
468
        response_format = '''HTTP/1.1 200 OK\r