'Test L{ftp.IWriteFile}: the implementation should have a receive
method returning a C{Deferred} which fires with a consumer ready to
receive data to be written. It should also have a close() method that
returns a Deferred.'

def test_write(self):

    content = 'elbbow\n'
    def cbGet(writer):
        return writer.receive().addCallback(cbReceive, writer)
    def cbReceive(consumer, writer):
        producer = TestProducer(content, consumer)
        consumer.registerProducer(None, True)
        producer.start()
        consumer.unregisterProducer()
        return writer.close().addCallback(cbClose)
    def cbClose(ignored):
        self.assertEqual(self.getFileContent(), content)
    return self.getFileWriter().addCallback(cbGet)
