]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
IFilesystemNode: add get_storage_index(), it makes tests easier
authorBrian Warner <warner@allmydata.com>
Tue, 12 Aug 2008 23:14:07 +0000 (16:14 -0700)
committerBrian Warner <warner@allmydata.com>
Tue, 12 Aug 2008 23:14:07 +0000 (16:14 -0700)
src/allmydata/dirnode.py
src/allmydata/immutable/filenode.py
src/allmydata/interfaces.py
src/allmydata/test/test_dirnode.py
src/allmydata/test/test_filenode.py
src/allmydata/test/test_mutable.py

index 3fa823eaeaafe91a34446aef18f300d338dfa291..a1b3ee93aecc80a346ec2118f922115b09c1ab73 100644 (file)
@@ -243,6 +243,9 @@ class NewDirectoryNode:
     def get_verifier(self):
         return self._uri.get_verifier().to_string()
 
+    def get_storage_index(self):
+        return self._uri._filenode_uri.storage_index
+
     def check(self, verify=False, repair=False):
         """Perform a file check. See IChecker.check for details."""
         return self._node.check(verify, repair)
index b6874265673b42f2b5be9c9cbc07f01010582429..54e883b0352864e159bfec5406fcfa7cce26840f 100644 (file)
@@ -44,6 +44,9 @@ class FileNode:
     def get_verifier(self):
         return self.u.get_verifier()
 
+    def get_storage_index(self):
+        return self.u.storage_index
+
     def check(self, verify=False, repair=False):
         assert repair is False  # not implemented yet
         storage_index = self.u.storage_index
@@ -113,6 +116,9 @@ class LiteralFileNode:
     def get_verifier(self):
         return None
 
+    def get_storage_index(self):
+        return None
+
     def check(self, verify=False, repair=False):
         # neither verify= nor repair= affect LIT files
         r = Results(None)
index 80de5ef67e624cbe77131a2ec3bfac056126bcde..19f4b126737625f8b6cb8060abc41a43cb482e07 100644 (file)
@@ -414,6 +414,11 @@ class IFilesystemNode(Interface):
         it holds a share for the file or directory.
         """
 
+    def get_storage_index():
+        """Return a string with the (binary) storage index in use on this
+        download. This may be None if there is no storage index (i.e. LIT
+        files)."""
+
     def check(verify=False, repair=False):
         """Perform a file check. See IChecker.check for details.
 
index 399f398910e45f642b0c29fbe7712561c34682df..4cd3163e87794f29f242f000934afa2b2a1ee8fb 100644 (file)
@@ -242,6 +242,8 @@ class Dirnode(unittest.TestCase, testutil.ShouldFailMixin, testutil.StallMixin):
             u_v = n.get_verifier()
             self.failUnless(u_v.startswith("URI:DIR2-Verifier:"), u_v)
             self.expected_manifest.append(u_v)
+            expected_si = n._uri._filenode_uri.storage_index
+            self.failUnlessEqual(n.get_storage_index(), expected_si)
 
             d = n.list()
             d.addCallback(lambda res: self.failUnlessEqual(res, {}))
index e1a4b17b3f12281ce320292633c892a8e1ddc1ca..04cc68d16ee4f81d52d539a35572575fc7ef9aaf 100644 (file)
@@ -27,6 +27,7 @@ class Node(unittest.TestCase):
         self.failUnlessEqual(fn1.is_mutable(), False)
         self.failUnlessEqual(fn1.get_readonly_uri(), u.to_string())
         self.failUnlessEqual(fn1.get_size(), 1000)
+        self.failUnlessEqual(fn1.get_storage_index(), u.storage_index)
         d = {}
         d[fn1] = 1 # exercise __hash__
         v = fn1.get_verifier()
@@ -47,6 +48,7 @@ class Node(unittest.TestCase):
         self.failUnlessEqual(fn1.is_mutable(), False)
         self.failUnlessEqual(fn1.get_readonly_uri(), u.to_string())
         self.failUnlessEqual(fn1.get_size(), len(DATA))
+        self.failUnlessEqual(fn1.get_storage_index(), None)
         d = {}
         d[fn1] = 1 # exercise __hash__
 
index 6abfe1bdcaf22218a151290474c5e7385950c33a..ca78bbb26a81672eae6a13c26687a1b5a47482af 100644 (file)
@@ -266,6 +266,7 @@ class Filenode(unittest.TestCase, testutil.ShouldFailMixin):
         d = self.client.create_mutable_file()
         def _created(n):
             self.failUnless(isinstance(n, FastMutableFileNode))
+            self.failUnlessEqual(n.get_storage_index(), n._storage_index)
             peer0 = self.client._peerids[0]
             shnums = self.client._storage._peers[peer0].keys()
             self.failUnlessEqual(len(shnums), 1)