d = basic.FileSender().beginFileTransfer(StringIO(data), consumer)
d.addCallback(lambda lastSent: consumer)
return d
+
+ # IReadable, IFileNode, IFilesystemNode
+ def get_best_readable_version(self):
+ return defer.succeed(self)
+
+
+ def download_best_version(self):
+ return defer.succeed(self.u.data)
+
+
+ download_to_data = download_best_version
+ get_size_of_best_version = get_current_size
def _check_segment(res):
self.failUnlessEqual(res, DATA[1:1+5])
d.addCallback(_check_segment)
+ d.addCallback(lambda ignored: fn1.get_best_readable_version())
+ d.addCallback(lambda fn2: self.failUnlessEqual(fn1, fn2))
+ d.addCallback(lambda ignored:
+ fn1.get_size_of_best_version())
+ d.addCallback(lambda size:
+ self.failUnlessEqual(size, len(DATA)))
+ d.addCallback(lambda ignored:
+ fn1.download_to_data())
+ d.addCallback(lambda data:
+ self.failUnlessEqual(data, DATA))
+ d.addCallback(lambda ignored:
+ fn1.download_best_version())
+ d.addCallback(lambda data:
+ self.failUnlessEqual(data, DATA))
return d