'If a L{Request} object completes its response while the transport is
paused, the L{HTTPChannel} does not resume the transport.'

def test_HTTPChannelStaysPausedWhenRequestCompletes(self):

    (channel, transport) = self.buildChannelAndTransport(StringTransport(), DelayedHTTPHandler)
    channel._optimisticEagerReadSize = 0
    channel.dataReceived(self.request)
    channel.dataReceived('extra')
    request = channel.requests[0].original
    producer = DummyProducer()
    request.registerProducer(producer, True)
    self.assertEqual(transport.producerState, 'paused')
    self.assertEqual(producer.events, [])
    channel.pauseProducing()
    self.assertEqual(transport.producerState, 'paused')
    self.assertEqual(producer.events, ['pause'])
    request.unregisterProducer()
    request.delayedProcess()
    self.assertEqual(transport.producerState, 'paused')
    channel.resumeProducing()
    self.assertEqual(transport.producerState, 'producing')
