~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport.py

Push the transport permutations list into each transport module allowing for automatic testing of new modules that are registered as transports.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
                           TransportNotPossible, ConnectionError)
25
25
from bzrlib.tests import TestCase, TestCaseInTempDir
26
26
from bzrlib.tests.HTTPTestUtil import TestCaseWithWebserver
27
 
from bzrlib.transport import memory, urlescape
 
27
from bzrlib.transport import (_get_protocol_handlers,
 
28
                              _get_transport_modules,
 
29
                              register_lazy_transport,
 
30
                              _set_protocol_handlers,
 
31
                              urlescape,
 
32
                              )
28
33
from bzrlib.osutils import pathjoin
29
34
 
30
35
 
57
62
    def test_urlescape(self):
58
63
        self.assertEqual('%25', urlescape('%'))
59
64
 
 
65
    def test__get_set_protocol_handlers(self):
 
66
        handlers = _get_protocol_handlers()
 
67
        self.assertNotEqual({}, handlers)
 
68
        try:
 
69
            _set_protocol_handlers({})
 
70
            self.assertEqual({}, _get_protocol_handlers())
 
71
        finally:
 
72
            _set_protocol_handlers(handlers)
 
73
 
 
74
    def test_get_transport_modules(self):
 
75
        handlers = _get_protocol_handlers()
 
76
        class SampleHandler(object):
 
77
            """I exist, isnt that enough?"""
 
78
        try:
 
79
            my_handlers = {}
 
80
            _set_protocol_handlers(my_handlers)
 
81
            register_lazy_transport('foo', 'bzrlib.tests.test_transport', 'TestTransport.SampleHandler')
 
82
            register_lazy_transport('bar', 'bzrlib.tests.test_transport', 'TestTransport.SampleHandler')
 
83
            self.assertEqual([SampleHandler.__module__],
 
84
                             _get_transport_modules())
 
85
        finally:
 
86
            _set_protocol_handlers(handlers)
 
87
            
60
88
 
61
89
class TestTransportMixIn(object):
62
90
    """Subclass this, and it will provide a series of tests for a Transport.