76
79
set_test_transport_to_sftp(self)
79
class SFTPLockTests (TestCaseWithSFTPServer):
82
class SFTPLockTests(TestCaseWithSFTPServer):
81
84
def test_sftp_locks(self):
82
85
from bzrlib.errors import LockError
459
462
self.assertAlmostEqual(t2 - t1, 100 + 7)
465
class Test_SFTPReadvHelper(tests.TestCase):
467
def checkGetRequests(self, expected_requests, offsets):
468
if not paramiko_loaded:
469
raise TestSkipped('you must have paramiko to run this test')
470
helper = _mod_sftp._SFTPReadvHelper(offsets, 'artificial_test')
471
self.assertEqual(expected_requests, helper._get_requests())
473
def test__get_requests(self):
474
# Small single requests become a single readv request
475
self.checkGetRequests([(0, 100)],
476
[(0, 20), (30, 50), (20, 10), (80, 20)])
477
# Non-contiguous ranges are given as multiple requests
478
self.checkGetRequests([(0, 20), (30, 50)],
479
[(10, 10), (30, 20), (0, 10), (50, 30)])
480
# Ranges larger than _max_request_size (32kB) are broken up into
481
# multiple requests, even if it actually spans multiple logical
483
self.checkGetRequests([(0, 32768), (32768, 32768), (65536, 464)],
484
[(0, 40000), (40000, 100), (40100, 1900),