32
32
from bzrlib.osutils import getcwd
33
33
from bzrlib.tests import TestCaseInTempDir, TestSkipped
34
from bzrlib.tests.test_transport import TestTransportImplementation
34
35
from bzrlib.transport import memory
35
36
import bzrlib.transport
36
37
import bzrlib.urlutils as urlutils
48
class TestTransportImplementation(TestCaseInTempDir):
49
"""Implementation verification for transports.
51
To verify a transport we need a server factory, which is a callable
52
that accepts no parameters and returns an implementation of
53
bzrlib.transport.Server.
55
That Server is then used to construct transport instances and test
56
the transport via loopback activity.
58
Currently this assumes that the Transport object is connected to the
59
current working directory. So that whatever is done
60
through the transport, should show up in the working
61
directory, and vice-versa. This is a bug, because its possible to have
62
URL schemes which provide access to something that may not be
63
result in storage on the local disk, i.e. due to file system limits, or
64
due to it being a database or some other non-filesystem tool.
66
This also tests to make sure that the functions work with both
67
generators and lists (assuming iter(list) is effectively a generator)
71
super(TestTransportImplementation, self).setUp()
72
self._server = self.transport_server()
76
super(TestTransportImplementation, self).tearDown()
77
self._server.tearDown()
49
class TransportTests(TestTransportImplementation):
79
51
def check_transport_contents(self, content, transport, relpath):
80
52
"""Check that transport.get(relpath).read() == content."""
81
53
self.assertEqualDiff(content, transport.get(relpath).read())
83
def get_transport(self):
84
"""Return a connected transport to the local directory."""
85
base_url = self._server.get_url()
86
t = bzrlib.transport.get_transport(base_url)
87
if not isinstance(t, self.transport_class):
88
# we want to make sure to construct one particular class, even if
89
# there are several available implementations of this transport;
90
# therefore construct it by hand rather than through the regular
91
# get_transport method
92
t = self.transport_class(base_url)
95
55
def assertListRaises(self, excClass, func, *args, **kwargs):
96
56
"""Fail unless excClass is raised when the iterator from func is used.