/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_sftp_transport.py

  • Committer: Andrew Bennetts
  • Date: 2008-10-01 05:40:45 UTC
  • mfrom: (3753 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3756.
  • Revision ID: andrew.bennetts@canonical.com-20081001054045-z50qc0d3p9qsc5im
Merge from bzr.dev; resolve osutils.py conflict by reverting my sha import hackery.

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
        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())
 
472
 
 
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
 
482
        # requests
 
483
        self.checkGetRequests([(0, 32768), (32768, 32768), (65536, 464)],
 
484
                              [(0, 40000), (40000, 100), (40100, 1900),
 
485
                               (42000, 24000)])