28
transport as _mod_transport,
31
31
from bzrlib.transport import (
36
from bzrlib.errors import (DependencyNotPresent,
44
from bzrlib.tests import features, TestCase, TestCaseInTempDir
45
from bzrlib.transport import (_clear_protocol_handlers,
48
_get_protocol_handlers,
49
_set_protocol_handlers,
50
_get_transport_modules,
53
register_lazy_transport,
54
register_transport_proto,
57
from bzrlib.transport.chroot import ChrootServer
58
from bzrlib.transport.local import (LocalTransport,
59
EmulatedWin32LocalTransport)
60
from bzrlib.transport.pathfilter import PathFilteringServer
39
from bzrlib.tests import features
63
42
# TODO: Should possibly split transport-specific tests into their own files.
66
class TestTransport(TestCase):
45
class TestTransport(tests.TestCase):
67
46
"""Test the non transport-concrete class functionality."""
48
# FIXME: These tests should use addCleanup() and/or overrideAttr() instead
49
# of try/finally -- vila 20100205
69
51
def test__get_set_protocol_handlers(self):
70
handlers = _get_protocol_handlers()
52
handlers = transport._get_protocol_handlers()
71
53
self.assertNotEqual([], handlers.keys( ))
73
_clear_protocol_handlers()
74
self.assertEqual([], _get_protocol_handlers().keys())
55
transport._clear_protocol_handlers()
56
self.assertEqual([], transport._get_protocol_handlers().keys())
76
_set_protocol_handlers(handlers)
58
transport._set_protocol_handlers(handlers)
78
60
def test_get_transport_modules(self):
79
handlers = _get_protocol_handlers()
61
handlers = transport._get_protocol_handlers()
80
62
# don't pollute the current handlers
81
_clear_protocol_handlers()
63
transport._clear_protocol_handlers()
82
64
class SampleHandler(object):
83
65
"""I exist, isnt that enough?"""
85
_clear_protocol_handlers()
86
register_transport_proto('foo')
87
register_lazy_transport('foo', 'bzrlib.tests.test_transport',
88
'TestTransport.SampleHandler')
89
register_transport_proto('bar')
90
register_lazy_transport('bar', 'bzrlib.tests.test_transport',
91
'TestTransport.SampleHandler')
67
transport._clear_protocol_handlers()
68
transport.register_transport_proto('foo')
69
transport.register_lazy_transport('foo',
70
'bzrlib.tests.test_transport',
71
'TestTransport.SampleHandler')
72
transport.register_transport_proto('bar')
73
transport.register_lazy_transport('bar',
74
'bzrlib.tests.test_transport',
75
'TestTransport.SampleHandler')
92
76
self.assertEqual([SampleHandler.__module__,
93
77
'bzrlib.transport.chroot',
94
78
'bzrlib.transport.pathfilter'],
95
_get_transport_modules())
79
transport._get_transport_modules())
97
_set_protocol_handlers(handlers)
81
transport._set_protocol_handlers(handlers)
99
83
def test_transport_dependency(self):
100
84
"""Transport with missing dependency causes no error"""
101
saved_handlers = _get_protocol_handlers()
85
saved_handlers = transport._get_protocol_handlers()
102
86
# don't pollute the current handlers
103
_clear_protocol_handlers()
87
transport._clear_protocol_handlers()
105
register_transport_proto('foo')
106
register_lazy_transport('foo', 'bzrlib.tests.test_transport',
107
'BadTransportHandler')
89
transport.register_transport_proto('foo')
90
transport.register_lazy_transport(
91
'foo', 'bzrlib.tests.test_transport', 'BadTransportHandler')
109
get_transport('foo://fooserver/foo')
110
except UnsupportedProtocol, e:
93
transport.get_transport('foo://fooserver/foo')
94
except errors.UnsupportedProtocol, e:
112
96
self.assertEquals('Unsupported protocol'
113
97
' for url "foo://fooserver/foo":'
117
101
self.fail('Did not raise UnsupportedProtocol')
119
103
# restore original values
120
_set_protocol_handlers(saved_handlers)
104
transport._set_protocol_handlers(saved_handlers)
122
106
def test_transport_fallback(self):
123
107
"""Transport with missing dependency causes no error"""
124
saved_handlers = _get_protocol_handlers()
108
saved_handlers = transport._get_protocol_handlers()
126
_clear_protocol_handlers()
127
register_transport_proto('foo')
128
register_lazy_transport('foo', 'bzrlib.tests.test_transport',
129
'BackupTransportHandler')
130
register_lazy_transport('foo', 'bzrlib.tests.test_transport',
131
'BadTransportHandler')
132
t = get_transport('foo://fooserver/foo')
110
transport._clear_protocol_handlers()
111
transport.register_transport_proto('foo')
112
transport.register_lazy_transport(
113
'foo', 'bzrlib.tests.test_transport', 'BackupTransportHandler')
114
transport.register_lazy_transport(
115
'foo', 'bzrlib.tests.test_transport', 'BadTransportHandler')
116
t = transport.get_transport('foo://fooserver/foo')
133
117
self.assertTrue(isinstance(t, BackupTransportHandler))
135
_set_protocol_handlers(saved_handlers)
119
transport._set_protocol_handlers(saved_handlers)
137
121
def test_ssh_hints(self):
138
122
"""Transport ssh:// should raise an error pointing out bzr+ssh://"""
140
get_transport('ssh://fooserver/foo')
141
except UnsupportedProtocol, e:
124
transport.get_transport('ssh://fooserver/foo')
125
except errors.UnsupportedProtocol, e:
143
127
self.assertEquals('Unsupported protocol'
144
128
' for url "ssh://fooserver/foo":'
145
' bzr supports bzr+ssh to operate over ssh, use "bzr+ssh://fooserver/foo".',
129
' bzr supports bzr+ssh to operate over ssh,'
130
' use "bzr+ssh://fooserver/foo".',
148
133
self.fail('Did not raise UnsupportedProtocol')
150
135
def test_LateReadError(self):
151
136
"""The LateReadError helper should raise on read()."""
152
a_file = LateReadError('a path')
137
a_file = transport.LateReadError('a path')
155
except ReadError, error:
140
except errors.ReadError, error:
156
141
self.assertEqual('a path', error.path)
157
self.assertRaises(ReadError, a_file.read, 40)
142
self.assertRaises(errors.ReadError, a_file.read, 40)
160
145
def test__combine_paths(self):
146
t = transport.Transport('/')
162
147
self.assertEqual('/home/sarah/project/foo',
163
148
t._combine_paths('/home/sarah', 'project/foo'))
164
149
self.assertEqual('/etc',
260
245
max_size=1*1024*1024*1024)
263
class TestMemoryServer(TestCase):
248
class TestMemoryServer(tests.TestCase):
265
250
def test_create_server(self):
266
251
server = memory.MemoryServer()
267
252
server.start_server()
268
253
url = server.get_url()
269
self.assertTrue(url in _mod_transport.transport_list_registry)
270
t = _mod_transport.get_transport(url)
254
self.assertTrue(url in transport.transport_list_registry)
255
t = transport.get_transport(url)
272
257
server.stop_server()
273
self.assertFalse(url in _mod_transport.transport_list_registry)
258
self.assertFalse(url in transport.transport_list_registry)
274
259
self.assertRaises(errors.UnsupportedProtocol,
275
_mod_transport.get_transport, url)
278
class TestMemoryTransport(TestCase):
260
transport.get_transport, url)
263
class TestMemoryTransport(tests.TestCase):
280
265
def test_get_transport(self):
281
266
memory.MemoryTransport()
283
268
def test_clone(self):
284
transport = memory.MemoryTransport()
285
self.assertTrue(isinstance(transport, memory.MemoryTransport))
286
self.assertEqual("memory:///", transport.clone("/").base)
269
t = memory.MemoryTransport()
270
self.assertTrue(isinstance(t, memory.MemoryTransport))
271
self.assertEqual("memory:///", t.clone("/").base)
288
273
def test_abspath(self):
289
transport = memory.MemoryTransport()
290
self.assertEqual("memory:///relpath", transport.abspath('relpath'))
274
t = memory.MemoryTransport()
275
self.assertEqual("memory:///relpath", t.abspath('relpath'))
292
277
def test_abspath_of_root(self):
293
transport = memory.MemoryTransport()
294
self.assertEqual("memory:///", transport.base)
295
self.assertEqual("memory:///", transport.abspath('/'))
278
t = memory.MemoryTransport()
279
self.assertEqual("memory:///", t.base)
280
self.assertEqual("memory:///", t.abspath('/'))
297
282
def test_abspath_of_relpath_starting_at_root(self):
298
transport = memory.MemoryTransport()
299
self.assertEqual("memory:///foo", transport.abspath('/foo'))
283
t = memory.MemoryTransport()
284
self.assertEqual("memory:///foo", t.abspath('/foo'))
301
286
def test_append_and_get(self):
302
transport = memory.MemoryTransport()
303
transport.append_bytes('path', 'content')
304
self.assertEqual(transport.get('path').read(), 'content')
305
transport.append_file('path', StringIO('content'))
306
self.assertEqual(transport.get('path').read(), 'contentcontent')
287
t = memory.MemoryTransport()
288
t.append_bytes('path', 'content')
289
self.assertEqual(t.get('path').read(), 'content')
290
t.append_file('path', StringIO('content'))
291
self.assertEqual(t.get('path').read(), 'contentcontent')
308
293
def test_put_and_get(self):
309
transport = memory.MemoryTransport()
310
transport.put_file('path', StringIO('content'))
311
self.assertEqual(transport.get('path').read(), 'content')
312
transport.put_bytes('path', 'content')
313
self.assertEqual(transport.get('path').read(), 'content')
294
t = memory.MemoryTransport()
295
t.put_file('path', StringIO('content'))
296
self.assertEqual(t.get('path').read(), 'content')
297
t.put_bytes('path', 'content')
298
self.assertEqual(t.get('path').read(), 'content')
315
300
def test_append_without_dir_fails(self):
316
transport = memory.MemoryTransport()
317
self.assertRaises(NoSuchFile,
318
transport.append_bytes, 'dir/path', 'content')
301
t = memory.MemoryTransport()
302
self.assertRaises(errors.NoSuchFile,
303
t.append_bytes, 'dir/path', 'content')
320
305
def test_put_without_dir_fails(self):
321
transport = memory.MemoryTransport()
322
self.assertRaises(NoSuchFile,
323
transport.put_file, 'dir/path', StringIO('content'))
306
t = memory.MemoryTransport()
307
self.assertRaises(errors.NoSuchFile,
308
t.put_file, 'dir/path', StringIO('content'))
325
310
def test_get_missing(self):
326
311
transport = memory.MemoryTransport()
327
self.assertRaises(NoSuchFile, transport.get, 'foo')
312
self.assertRaises(errors.NoSuchFile, transport.get, 'foo')
329
314
def test_has_missing(self):
330
transport = memory.MemoryTransport()
331
self.assertEquals(False, transport.has('foo'))
315
t = memory.MemoryTransport()
316
self.assertEquals(False, t.has('foo'))
333
318
def test_has_present(self):
334
transport = memory.MemoryTransport()
335
transport.append_bytes('foo', 'content')
336
self.assertEquals(True, transport.has('foo'))
319
t = memory.MemoryTransport()
320
t.append_bytes('foo', 'content')
321
self.assertEquals(True, t.has('foo'))
338
323
def test_list_dir(self):
339
transport = memory.MemoryTransport()
340
transport.put_bytes('foo', 'content')
341
transport.mkdir('dir')
342
transport.put_bytes('dir/subfoo', 'content')
343
transport.put_bytes('dirlike', 'content')
324
t = memory.MemoryTransport()
325
t.put_bytes('foo', 'content')
327
t.put_bytes('dir/subfoo', 'content')
328
t.put_bytes('dirlike', 'content')
345
self.assertEquals(['dir', 'dirlike', 'foo'], sorted(transport.list_dir('.')))
346
self.assertEquals(['subfoo'], sorted(transport.list_dir('dir')))
330
self.assertEquals(['dir', 'dirlike', 'foo'], sorted(t.list_dir('.')))
331
self.assertEquals(['subfoo'], sorted(t.list_dir('dir')))
348
333
def test_mkdir(self):
349
transport = memory.MemoryTransport()
350
transport.mkdir('dir')
351
transport.append_bytes('dir/path', 'content')
352
self.assertEqual(transport.get('dir/path').read(), 'content')
334
t = memory.MemoryTransport()
336
t.append_bytes('dir/path', 'content')
337
self.assertEqual(t.get('dir/path').read(), 'content')
354
339
def test_mkdir_missing_parent(self):
355
transport = memory.MemoryTransport()
356
self.assertRaises(NoSuchFile,
357
transport.mkdir, 'dir/dir')
340
t = memory.MemoryTransport()
341
self.assertRaises(errors.NoSuchFile, t.mkdir, 'dir/dir')
359
343
def test_mkdir_twice(self):
360
transport = memory.MemoryTransport()
361
transport.mkdir('dir')
362
self.assertRaises(FileExists, transport.mkdir, 'dir')
344
t = memory.MemoryTransport()
346
self.assertRaises(errors.FileExists, t.mkdir, 'dir')
364
348
def test_parameters(self):
365
transport = memory.MemoryTransport()
366
self.assertEqual(True, transport.listable())
367
self.assertEqual(False, transport.is_readonly())
349
t = memory.MemoryTransport()
350
self.assertEqual(True, t.listable())
351
self.assertEqual(False, t.is_readonly())
369
353
def test_iter_files_recursive(self):
370
transport = memory.MemoryTransport()
371
transport.mkdir('dir')
372
transport.put_bytes('dir/foo', 'content')
373
transport.put_bytes('dir/bar', 'content')
374
transport.put_bytes('bar', 'content')
375
paths = set(transport.iter_files_recursive())
354
t = memory.MemoryTransport()
356
t.put_bytes('dir/foo', 'content')
357
t.put_bytes('dir/bar', 'content')
358
t.put_bytes('bar', 'content')
359
paths = set(t.iter_files_recursive())
376
360
self.assertEqual(set(['dir/foo', 'dir/bar', 'bar']), paths)
378
362
def test_stat(self):
379
transport = memory.MemoryTransport()
380
transport.put_bytes('foo', 'content')
381
transport.put_bytes('bar', 'phowar')
382
self.assertEqual(7, transport.stat('foo').st_size)
383
self.assertEqual(6, transport.stat('bar').st_size)
386
class ChrootDecoratorTransportTest(TestCase):
363
t = memory.MemoryTransport()
364
t.put_bytes('foo', 'content')
365
t.put_bytes('bar', 'phowar')
366
self.assertEqual(7, t.stat('foo').st_size)
367
self.assertEqual(6, t.stat('bar').st_size)
370
class ChrootDecoratorTransportTest(tests.TestCase):
387
371
"""Chroot decoration specific tests."""
389
373
def test_abspath(self):
390
374
# The abspath is always relative to the chroot_url.
391
server = ChrootServer(get_transport('memory:///foo/bar/'))
375
server = chroot.ChrootServer(
376
transport.get_transport('memory:///foo/bar/'))
392
377
self.start_server(server)
393
transport = get_transport(server.get_url())
394
self.assertEqual(server.get_url(), transport.abspath('/'))
378
t = transport.get_transport(server.get_url())
379
self.assertEqual(server.get_url(), t.abspath('/'))
396
subdir_transport = transport.clone('subdir')
397
self.assertEqual(server.get_url(), subdir_transport.abspath('/'))
381
subdir_t = t.clone('subdir')
382
self.assertEqual(server.get_url(), subdir_t.abspath('/'))
399
384
def test_clone(self):
400
server = ChrootServer(get_transport('memory:///foo/bar/'))
385
server = chroot.ChrootServer(
386
transport.get_transport('memory:///foo/bar/'))
401
387
self.start_server(server)
402
transport = get_transport(server.get_url())
388
t = transport.get_transport(server.get_url())
403
389
# relpath from root and root path are the same
404
relpath_cloned = transport.clone('foo')
405
abspath_cloned = transport.clone('/foo')
390
relpath_cloned = t.clone('foo')
391
abspath_cloned = t.clone('/foo')
406
392
self.assertEqual(server, relpath_cloned.server)
407
393
self.assertEqual(server, abspath_cloned.server)
494
484
parameter to override it."""
495
485
if filter_func is None:
496
486
filter_func = lambda x: x
497
server = PathFilteringServer(
498
get_transport('memory:///foo/bar/'), filter_func)
487
server = pathfilter.PathFilteringServer(
488
transport.get_transport('memory:///foo/bar/'), filter_func)
499
489
server.start_server()
500
490
self.addCleanup(server.stop_server)
501
return get_transport(server.get_url())
491
return transport.get_transport(server.get_url())
503
493
def test__filter(self):
504
494
# _filter (with an identity func as filter_func) always returns
505
495
# paths relative to the base of the backing transport.
506
transport = self.make_pf_transport()
507
self.assertEqual('foo', transport._filter('foo'))
508
self.assertEqual('foo/bar', transport._filter('foo/bar'))
509
self.assertEqual('', transport._filter('..'))
510
self.assertEqual('', transport._filter('/'))
496
t = self.make_pf_transport()
497
self.assertEqual('foo', t._filter('foo'))
498
self.assertEqual('foo/bar', t._filter('foo/bar'))
499
self.assertEqual('', t._filter('..'))
500
self.assertEqual('', t._filter('/'))
511
501
# The base of the pathfiltering transport is taken into account too.
512
transport = transport.clone('subdir1/subdir2')
513
self.assertEqual('subdir1/subdir2/foo', transport._filter('foo'))
515
'subdir1/subdir2/foo/bar', transport._filter('foo/bar'))
516
self.assertEqual('subdir1', transport._filter('..'))
517
self.assertEqual('', transport._filter('/'))
502
t = t.clone('subdir1/subdir2')
503
self.assertEqual('subdir1/subdir2/foo', t._filter('foo'))
504
self.assertEqual('subdir1/subdir2/foo/bar', t._filter('foo/bar'))
505
self.assertEqual('subdir1', t._filter('..'))
506
self.assertEqual('', t._filter('/'))
519
508
def test_filter_invocation(self):
521
510
def filter(path):
522
511
filter_log.append(path)
524
transport = self.make_pf_transport(filter)
513
t = self.make_pf_transport(filter)
526
515
self.assertEqual(['abc'], filter_log)
527
516
del filter_log[:]
528
transport.clone('abc').has('xyz')
517
t.clone('abc').has('xyz')
529
518
self.assertEqual(['abc/xyz'], filter_log)
530
519
del filter_log[:]
531
transport.has('/abc')
532
521
self.assertEqual(['abc'], filter_log)
534
523
def test_clone(self):
535
transport = self.make_pf_transport()
524
t = self.make_pf_transport()
536
525
# relpath from root and root path are the same
537
relpath_cloned = transport.clone('foo')
538
abspath_cloned = transport.clone('/foo')
539
self.assertEqual(transport.server, relpath_cloned.server)
540
self.assertEqual(transport.server, abspath_cloned.server)
526
relpath_cloned = t.clone('foo')
527
abspath_cloned = t.clone('/foo')
528
self.assertEqual(t.server, relpath_cloned.server)
529
self.assertEqual(t.server, abspath_cloned.server)
542
531
def test_url_preserves_pathfiltering(self):
543
532
"""Calling get_transport on a pathfiltered transport's base should
548
537
otherwise) the filtering by doing::
549
538
url = filtered_transport.base
550
539
parent_url = urlutils.join(url, '..')
551
new_transport = get_transport(parent_url)
540
new_t = transport.get_transport(parent_url)
553
transport = self.make_pf_transport()
554
new_transport = get_transport(transport.base)
555
self.assertEqual(transport.server, new_transport.server)
556
self.assertEqual(transport.base, new_transport.base)
559
class ReadonlyDecoratorTransportTest(TestCase):
542
t = self.make_pf_transport()
543
new_t = transport.get_transport(t.base)
544
self.assertEqual(t.server, new_t.server)
545
self.assertEqual(t.base, new_t.base)
548
class ReadonlyDecoratorTransportTest(tests.TestCase):
560
549
"""Readonly decoration specific tests."""
562
551
def test_local_parameters(self):
563
552
# connect to . in readonly mode
564
transport = readonly.ReadonlyTransportDecorator('readonly+.')
565
self.assertEqual(True, transport.listable())
566
self.assertEqual(True, transport.is_readonly())
553
t = readonly.ReadonlyTransportDecorator('readonly+.')
554
self.assertEqual(True, t.listable())
555
self.assertEqual(True, t.is_readonly())
568
557
def test_http_parameters(self):
569
558
from bzrlib.tests.http_server import HttpServer
570
559
# connect to '.' via http which is not listable
571
560
server = HttpServer()
572
561
self.start_server(server)
573
transport = get_transport('readonly+' + server.get_url())
574
self.failUnless(isinstance(transport,
575
readonly.ReadonlyTransportDecorator))
576
self.assertEqual(False, transport.listable())
577
self.assertEqual(True, transport.is_readonly())
580
class FakeNFSDecoratorTests(TestCaseInTempDir):
562
t = transport.get_transport('readonly+' + server.get_url())
563
self.failUnless(isinstance(t, readonly.ReadonlyTransportDecorator))
564
self.assertEqual(False, t.listable())
565
self.assertEqual(True, t.is_readonly())
568
class FakeNFSDecoratorTests(tests.TestCaseInTempDir):
581
569
"""NFS decorator specific tests."""
583
571
def get_nfs_transport(self, url):
829
818
self.assertIs(new_password, c._get_credentials())
832
class TestReusedTransports(TestCase):
821
class TestReusedTransports(tests.TestCase):
833
822
"""Tests for transport reuse"""
835
824
def test_reuse_same_transport(self):
836
825
possible_transports = []
837
t1 = get_transport('http://foo/',
838
possible_transports=possible_transports)
826
t1 = transport.get_transport('http://foo/',
827
possible_transports=possible_transports)
839
828
self.assertEqual([t1], possible_transports)
840
t2 = get_transport('http://foo/', possible_transports=[t1])
829
t2 = transport.get_transport('http://foo/',
830
possible_transports=[t1])
841
831
self.assertIs(t1, t2)
843
833
# Also check that final '/' are handled correctly
844
t3 = get_transport('http://foo/path/')
845
t4 = get_transport('http://foo/path', possible_transports=[t3])
834
t3 = transport.get_transport('http://foo/path/')
835
t4 = transport.get_transport('http://foo/path',
836
possible_transports=[t3])
846
837
self.assertIs(t3, t4)
848
t5 = get_transport('http://foo/path')
849
t6 = get_transport('http://foo/path/', possible_transports=[t5])
839
t5 = transport.get_transport('http://foo/path')
840
t6 = transport.get_transport('http://foo/path/',
841
possible_transports=[t5])
850
842
self.assertIs(t5, t6)
852
844
def test_don_t_reuse_different_transport(self):
853
t1 = get_transport('http://foo/path')
854
t2 = get_transport('http://bar/path', possible_transports=[t1])
845
t1 = transport.get_transport('http://foo/path')
846
t2 = transport.get_transport('http://bar/path',
847
possible_transports=[t1])
855
848
self.assertIsNot(t1, t2)
858
class TestTransportTrace(TestCase):
851
class TestTransportTrace(tests.TestCase):
860
853
def test_get(self):
861
transport = get_transport('trace+memory://')
862
self.assertIsInstance(
863
transport, bzrlib.transport.trace.TransportTraceDecorator)
854
t = transport.get_transport('trace+memory://')
855
self.assertIsInstance(t, bzrlib.transport.trace.TransportTraceDecorator)
865
857
def test_clone_preserves_activity(self):
866
transport = get_transport('trace+memory://')
867
transport2 = transport.clone('.')
868
self.assertTrue(transport is not transport2)
869
self.assertTrue(transport._activity is transport2._activity)
858
t = transport.get_transport('trace+memory://')
860
self.assertTrue(t is not t2)
861
self.assertTrue(t._activity is t2._activity)
871
863
# the following specific tests are for the operations that have made use of
872
864
# logging in tests; we could test every single operation but doing that
873
865
# still won't cause a test failure when the top level Transport API
874
866
# changes; so there is little return doing that.
875
867
def test_get(self):
876
transport = get_transport('trace+memory:///')
877
transport.put_bytes('foo', 'barish')
868
t = transport.get_transport('trace+memory:///')
869
t.put_bytes('foo', 'barish')
879
871
expected_result = []
880
872
# put_bytes records the bytes, not the content to avoid memory
882
874
expected_result.append(('put_bytes', 'foo', 6, None))
883
875
# get records the file name only.
884
876
expected_result.append(('get', 'foo'))
885
self.assertEqual(expected_result, transport._activity)
877
self.assertEqual(expected_result, t._activity)
887
879
def test_readv(self):
888
transport = get_transport('trace+memory:///')
889
transport.put_bytes('foo', 'barish')
890
list(transport.readv('foo', [(0, 1), (3, 2)], adjust_for_latency=True,
880
t = transport.get_transport('trace+memory:///')
881
t.put_bytes('foo', 'barish')
882
list(t.readv('foo', [(0, 1), (3, 2)],
883
adjust_for_latency=True, upper_limit=6))
892
884
expected_result = []
893
885
# put_bytes records the bytes, not the content to avoid memory
895
887
expected_result.append(('put_bytes', 'foo', 6, None))
896
888
# readv records the supplied offset request
897
889
expected_result.append(('readv', 'foo', [(0, 1), (3, 2)], True, 6))
898
self.assertEqual(expected_result, transport._activity)
890
self.assertEqual(expected_result, t._activity)
901
893
class TestSSHConnections(tests.TestCaseWithTransport):