'If L{Request} is created with a C{bodyProducer} with a known length and
the producer does not produce that many bytes, the L{Deferred} returned
by L{Request.writeTo} fires with a L{Failure} wrapping a
L{WrongBodyLength} exception.'

def test_sendRequestBodyWithTooFewBytes(self):

    producer = StringProducer(3)
    request = Request('POST', '/bar', _boringHeaders, producer)
    writeDeferred = request.writeTo(self.transport)
    producer.consumer.write('ab')
    producer.finished.callback(None)
    self.assertIdentical(self.transport.producer, None)
    return self.assertFailure(writeDeferred, WrongBodyLength)
