~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_transport.py

Merge cleanup into description

Show diffs side-by-side

added added

removed removed

Lines of Context:
2892
2892
        self.assertWriteCount(1)
2893
2893
 
2894
2894
    def test_send_response_with_body_stream_flushes_buffers_sometimes(self):
2895
 
        """When there are many chunks (>100), multiple writes will occur rather
 
2895
        """When there are many bytes (>1MB), multiple writes will occur rather
2896
2896
        than buffering indefinitely.
2897
2897
        """
2898
 
        # Construct a response with stream with 40 chunks in it.  Every chunk
2899
 
        # triggers 3 buffered writes, so we expect > 100 buffered writes, but <
2900
 
        # 200.
2901
 
        body_stream = ['chunk %d' % count for count in range(40)]
 
2898
        # Construct a response with stream with ~1.5MB in it. This should
 
2899
        # trigger 2 writes, but not 3
 
2900
        onekib = '12345678' * 128
 
2901
        body_stream = [onekib] * (1024 + 512)
2902
2902
        response = _mod_request.SuccessfulSmartServerResponse(
2903
2903
            ('arg', 'arg'), body_stream=body_stream)
2904
2904
        self.responder.send_response(response)
2905
 
        # The write buffer is flushed every 100 buffered writes, so we expect 2
2906
 
        # actual writes.
2907
2905
        self.assertWriteCount(2)
2908
2906
 
2909
2907