From: Kevan Carstensen Date: Tue, 2 Aug 2011 02:08:14 +0000 (-0700) Subject: immutable/literal.py: Implement interface changes in literal nodes. X-Git-Tag: trac-5200~24 X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/css/?a=commitdiff_plain;h=3e996e0c94e9778717e18927e2d05d67fd6490c0;p=tahoe-lafs%2Ftahoe-lafs.git immutable/literal.py: Implement interface changes in literal nodes. --- diff --git a/src/allmydata/immutable/literal.py b/src/allmydata/immutable/literal.py index 09466cb8..16effaa4 100644 --- a/src/allmydata/immutable/literal.py +++ b/src/allmydata/immutable/literal.py @@ -102,3 +102,15 @@ class LiteralFileNode(_ImmutableFileNodeBase): 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 diff --git a/src/allmydata/test/test_filenode.py b/src/allmydata/test/test_filenode.py index 61bb0e8e..abc74981 100644 --- a/src/allmydata/test/test_filenode.py +++ b/src/allmydata/test/test_filenode.py @@ -95,6 +95,20 @@ class Node(unittest.TestCase): 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