74
75
def test_get_transport_modules(self):
75
76
handlers = _get_protocol_handlers()
77
# don't pollute the current handlers
78
_clear_protocol_handlers()
76
79
class SampleHandler(object):
77
80
"""I exist, isnt that enough?"""
89
92
def test_transport_dependency(self):
90
93
"""Transport with missing dependency causes no error"""
91
94
saved_handlers = _get_protocol_handlers()
95
# don't pollute the current handlers
96
_clear_protocol_handlers()
93
98
register_transport_proto('foo')
94
99
register_lazy_transport('foo', 'bzrlib.tests.test_transport',
712
717
self.assertIsNot(t1, t2)
715
def get_test_permutations():
716
"""Return transport permutations to be used in testing.
718
This module registers some transports, but they're only for testing
719
registration. We don't really want to run all the transport tests against
720
class TestTransportTrace(TestCase):
723
transport = get_transport('trace+memory://')
724
self.assertIsInstance(
725
transport, bzrlib.transport.trace.TransportTraceDecorator)
727
def test_clone_preserves_activity(self):
728
transport = get_transport('trace+memory://')
729
transport2 = transport.clone('.')
730
self.assertTrue(transport is not transport2)
731
self.assertTrue(transport._activity is transport2._activity)
733
# the following specific tests are for the operations that have made use of
734
# logging in tests; we could test every single operation but doing that
735
# still won't cause a test failure when the top level Transport API
736
# changes; so there is little return doing that.
738
transport = get_transport('trace+memory:///')
739
transport.put_bytes('foo', 'barish')
742
# put_bytes records the bytes, not the content to avoid memory
744
expected_result.append(('put_bytes', 'foo', 6, None))
745
# get records the file name only.
746
expected_result.append(('get', 'foo'))
747
self.assertEqual(expected_result, transport._activity)
749
def test_readv(self):
750
transport = get_transport('trace+memory:///')
751
transport.put_bytes('foo', 'barish')
752
list(transport.readv('foo', [(0, 1), (3, 2)], adjust_for_latency=True,
755
# put_bytes records the bytes, not the content to avoid memory
757
expected_result.append(('put_bytes', 'foo', 6, None))
758
# readv records the supplied offset request
759
expected_result.append(('readv', 'foo', [(0, 1), (3, 2)], True, 6))
760
self.assertEqual(expected_result, transport._activity)