72
72
register_lazy_transport('foo', 'bzrlib.tests.test_transport',
73
73
'BadTransportHandler')
74
# TODO: jam 20060427 Now we get InvalidURL because it looks like
75
# a URL but we have no support for it.
76
# Is it better to always fall back to LocalTransport?
77
# I think this is a better error than a future NoSuchFile
78
self.assertRaises(InvalidURL, get_transport, 'foo://fooserver/foo')
75
get_transport('foo://fooserver/foo')
76
except UnsupportedProtocol, e:
78
self.assertEquals('Unsupported protocol'
79
' for url "foo://fooserver/foo":'
80
' Unable to import library "some_lib":'
81
' testing missing dependency', str(e))
83
self.fail('Did not raise UnsupportedProtocol')
80
85
# restore original values
81
86
_set_protocol_handlers(saved_handlers)
306
311
class BackupTransportHandler(Transport):
307
312
"""Test transport that works as a backup for the BadTransportHandler"""
316
class TestTransportImplementation(TestCaseInTempDir):
317
"""Implementation verification for transports.
319
To verify a transport we need a server factory, which is a callable
320
that accepts no parameters and returns an implementation of
321
bzrlib.transport.Server.
323
That Server is then used to construct transport instances and test
324
the transport via loopback activity.
326
Currently this assumes that the Transport object is connected to the
327
current working directory. So that whatever is done
328
through the transport, should show up in the working
329
directory, and vice-versa. This is a bug, because its possible to have
330
URL schemes which provide access to something that may not be
331
result in storage on the local disk, i.e. due to file system limits, or
332
due to it being a database or some other non-filesystem tool.
334
This also tests to make sure that the functions work with both
335
generators and lists (assuming iter(list) is effectively a generator)
339
super(TestTransportImplementation, self).setUp()
340
self._server = self.transport_server()
344
super(TestTransportImplementation, self).tearDown()
345
self._server.tearDown()
347
def get_transport(self):
348
"""Return a connected transport to the local directory."""
349
base_url = self._server.get_url()
350
# try getting the transport via the regular interface:
351
t = get_transport(base_url)
352
if not isinstance(t, self.transport_class):
353
# we did not get the correct transport class type. Override the
354
# regular connection behaviour by direct construction.
355
t = self.transport_class(base_url)