~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart_request.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-03-02 06:21:02 UTC
  • mfrom: (4064.1.4 streaming-body-error)
  • Revision ID: pqm@pqm.ubuntu.com-20090302062102-9hcytxohu3q8qxan
Improve error-handling while sending body_streams in HPSS requests
        and responses. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
        handler.end_received()
44
44
        # Request done, no exception was raised.
45
45
 
46
 
    def test_unexpected_body(self):
47
 
        """If a request implementation receives an unexpected body, it
48
 
        raises an error.
49
 
        """
50
 
        # Create a SmartServerRequestHandler with a SmartServerRequest subclass
51
 
        # that does not implement do_body.
52
 
        handler = request.SmartServerRequestHandler(
53
 
            None, {'foo': NoBodyRequest}, '/')
54
 
        # Emulate a request with a body
55
 
        handler.args_received(('foo',))
56
 
        handler.accept_body('some body bytes')
57
 
        # Note that the exception currently occurs at the end of the request.
58
 
        # In principle it would also be ok for it to happen earlier, during
59
 
        # accept_body.
60
 
        exc = self.assertRaises(errors.SmartProtocolError, handler.end_received)
61
 
        self.assertEquals('Request does not expect a body', exc.details)
62