~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_transport.py

  • Committer: Andrew Bennetts
  • Date: 2009-03-02 03:38:29 UTC
  • mto: This revision was merged to the branch mainline in revision 4066.
  • Revision ID: andrew.bennetts@canonical.com-20090302033829-7fzta4klg2yshnut
Add TestResponseEncodingProtocolThree.test_send_broken_body_stream, and make it pass.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2817
2817
            # end of message
2818
2818
            'e')
2819
2819
 
 
2820
    def test_send_broken_body_stream(self):
 
2821
        encoder, out_stream = self.make_response_encoder()
 
2822
        encoder._headers = {}
 
2823
        def stream_that_fails():
 
2824
            yield 'aaa'
 
2825
            yield 'bbb'
 
2826
            raise Exception('Boom!')
 
2827
        response = _mod_request.SuccessfulSmartServerResponse(
 
2828
            ('args',), body_stream=stream_that_fails())
 
2829
        encoder.send_response(response)
 
2830
        self.assertEqual(
 
2831
            'bzr message 3 (bzr 1.6)\n'  # protocol marker
 
2832
            '\x00\x00\x00\x02de' # headers dict (empty)
 
2833
            'oS' # status flag (success)
 
2834
            's\x00\x00\x00\x08l4:argse' # args struct ('args,')
 
2835
            'b\x00\x00\x00\x03aaa' # body part ('aaa')
 
2836
            'b\x00\x00\x00\x03bbb' # body part ('bbb')
 
2837
            'oE' # status flag (error)
 
2838
            's\x00\x00\x00\x10l5:error5:Boom!e' # err struct ('error', 'Boom!')
 
2839
            'e' # EOM
 
2840
            , out_stream.getvalue())
 
2841
 
2820
2842
 
2821
2843
class TestResponseEncoderBufferingProtocolThree(tests.TestCase):
2822
2844
    """Tests for buffering of responses.