'C{writeSequence} pauses its streaming producer if too much data is
buffered, and then resumes it.'

def test_streamingProducer(self):

    @implementer(IPushProducer)
    class SaveActionProducer(object, ):
        client = None
        server = None
        def __init__(self):
            self.actions = []
        def pauseProducing(self):
            self.actions.append('pause')
        def resumeProducing(self):
            self.actions.append('resume')
            self.client.transport.unregisterProducer()
            self.server.transport.loseConnection()
        def stopProducing(self):
            self.actions.append('stop')
    producer = SaveActionProducer()
    def connected(protocols):
        (client, server) = protocols[:2]
        producer.client = client
        producer.server = server
        client.transport.registerProducer(producer, True)
        self.assertEqual(producer.actions, [])
        self.setWriteBufferSize(client.transport, 500)
        client.transport.writeSequence(([('x' * 50)] * 20))
        self.assertEqual(producer.actions, ['pause'])
    reactor = self.buildReactor()
    d = self.getConnectedClientAndServer(reactor, '127.0.0.1', socket.AF_INET)
    d.addCallback(connected)
    d.addErrback(log.err)
    self.runReactor(reactor)
    self.assertEqual(producer.actions, ['pause', 'resume'])
