~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_sftp_transport.py

  • Committer: Vincent Ladeuil
  • Date: 2008-09-11 19:36:38 UTC
  • mfrom: (3703 +trunk)
  • mto: (3705.1.1 trunk2)
  • mto: This revision was merged to the branch mainline in revision 3708.
  • Revision ID: v.ladeuil+lp@free.fr-20080911193638-wtjyc1kcmacc6t1f
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
from bzrlib import (
31
31
    bzrdir,
32
32
    errors,
 
33
    tests,
 
34
    transport as _mod_transport,
33
35
    )
34
36
from bzrlib.osutils import (
35
37
    pathjoin,
46
48
import bzrlib.transport.http
47
49
 
48
50
if paramiko_loaded:
 
51
    from bzrlib.transport import sftp as _mod_sftp
49
52
    from bzrlib.transport.sftp import (
50
53
        SFTPAbsoluteServer,
51
54
        SFTPHomeDirServer,
76
79
        set_test_transport_to_sftp(self)
77
80
 
78
81
 
79
 
class SFTPLockTests (TestCaseWithSFTPServer):
 
82
class SFTPLockTests(TestCaseWithSFTPServer):
80
83
 
81
84
    def test_sftp_locks(self):
82
85
        from bzrlib.errors import LockError
459
462
        self.assertAlmostEqual(t2 - t1, 100 + 7)
460
463
 
461
464
 
 
465
class Test_SFTPReadvHelper(tests.TestCase):
 
466
 
 
467
    def checkGetRequests(self, expected_requests, offsets):
 
468
        helper = _mod_sftp._SFTPReadvHelper(offsets, 'artificial_test')
 
469
        self.assertEqual(expected_requests, helper._get_requests())
 
470
 
 
471
    def test__get_requests(self):
 
472
        # Small single requests become a single readv request
 
473
        self.checkGetRequests([(0, 100)],
 
474
                              [(0, 20), (30, 50), (20, 10), (80, 20)])
 
475
        # Non-contiguous ranges are given as multiple requests
 
476
        self.checkGetRequests([(0, 20), (30, 50)],
 
477
                              [(10, 10), (30, 20), (0, 10), (50, 30)])
 
478
        # Ranges larger than _max_request_size (32kB) are broken up into
 
479
        # multiple requests, even if it actually spans multiple logical
 
480
        # requests
 
481
        self.checkGetRequests([(0, 32768), (32768, 32768), (65536, 464)],
 
482
                              [(0, 40000), (40000, 100), (40100, 1900),
 
483
                               (42000, 24000)])