immutable/literal.py: Implement interface changes in literal nodes.
authorKevan Carstensen <kevan@isnotajoke.com>
Tue, 2 Aug 2011 02:08:14 +0000 (19:08 -0700)
committerKevan Carstensen <kevan@isnotajoke.com>
Tue, 2 Aug 2011 02:08:14 +0000 (19:08 -0700)
src/allmydata/immutable/literal.py
src/allmydata/test/test_filenode.py

index 09466cb8d1416ad2130da06a593e414633004082..16effaa4d40a3e08a7e708bfa8c143e66de8d530 100644 (file)
@@ -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
index 61bb0e8eb5c12e8f40dcabf7aa4d70a8755d1f20..abc74981ff1b7129505961f5f7ec0e6a25d7020e 100644 (file)
@@ -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