'When L{basic.LineReceiver} is paused, it doesn\'t deliver lines to
L{basic.LineReceiver.lineReceived} and delivers them immediately upon
being resumed.
L{ConsumingProtocol} is a L{LineReceiver} that pauses itself after
every line, and writes that line to its transport.'

def test_pauseResume(self):

    p = ConsumingProtocol()
    t = OnlyProducerTransport()
    p.makeConnection(t)
    p.dataReceived('hello,    ')
    self.assertEqual(t.data, [])
    self.assertFalse(t.paused)
    self.assertFalse(p.paused)
    p.dataReceived('world\r\n')
    self.assertEqual(t.data, ['hello,    world'])
    self.assertTrue(t.paused)
    self.assertTrue(p.paused)
    p.resumeProducing()
    self.assertEqual(t.data, ['hello,    world'])
    self.assertFalse(t.paused)
    self.assertFalse(p.paused)
    p.dataReceived('hello\r\nworld\r\n')
    self.assertEqual(t.data, ['hello,    world', 'hello'])
    self.assertTrue(t.paused)
    self.assertTrue(p.paused)
    p.resumeProducing()
    self.assertEqual(t.data, ['hello,    world', 'hello', 'world'])
    self.assertTrue(t.paused)
    self.assertTrue(p.paused)
    p.dataReceived('goodbye\r\n')
    self.assertEqual(t.data, ['hello,    world', 'hello', 'world'])
    self.assertTrue(t.paused)
    self.assertTrue(p.paused)
    p.resumeProducing()
    self.assertEqual(t.data, ['hello,    world', 'hello', 'world', 'goodbye'])
    self.assertTrue(t.paused)
    self.assertTrue(p.paused)
    p.resumeProducing()
    self.assertEqual(t.data, ['hello,    world', 'hello', 'world', 'goodbye'])
    self.assertFalse(t.paused)
    self.assertFalse(p.paused)
