'Test that addWindowBytes adds bytes to the window and resumes writing
if it was paused.'

def test_addWindowBytes(self):

    cb = [False]
    def stubStartWriting():
        cb[0] = True
    self.channel.startWriting = stubStartWriting
    self.channel.write('test')
    self.channel.writeExtended(1, 'test')
    self.channel.addWindowBytes(50)
    self.assertEqual(self.channel.remoteWindowLeft, ((50 - 4) - 4))
    self.assertTrue(self.channel.areWriting)
    self.assertTrue(cb[0])
    self.assertEqual(self.channel.buf, '')
    self.assertEqual(self.conn.data[self.channel], ['test'])
    self.assertEqual(self.channel.extBuf, [])
    self.assertEqual(self.conn.extData[self.channel], [(1, 'test')])
    cb[0] = False
    self.channel.addWindowBytes(20)
    self.assertFalse(cb[0])
    self.channel.write(('a' * 80))
    self.channel.loseConnection()
    self.channel.addWindowBytes(20)
    self.assertFalse(cb[0])
