From: Brian Warner Date: Tue, 12 Aug 2008 23:14:07 +0000 (-0700) Subject: IFilesystemNode: add get_storage_index(), it makes tests easier X-Git-Url: https://git.rkrishnan.org/vdrive/%5B/%5D%20/uri/htmlfontify-example.html?a=commitdiff_plain;h=c80e3529513996ae4ac1ba816f46b4e6e62ba9e3;p=tahoe-lafs%2Ftahoe-lafs.git IFilesystemNode: add get_storage_index(), it makes tests easier --- diff --git a/src/allmydata/dirnode.py b/src/allmydata/dirnode.py index 3fa823ea..a1b3ee93 100644 --- a/src/allmydata/dirnode.py +++ b/src/allmydata/dirnode.py @@ -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) diff --git a/src/allmydata/immutable/filenode.py b/src/allmydata/immutable/filenode.py index b6874265..54e883b0 100644 --- a/src/allmydata/immutable/filenode.py +++ b/src/allmydata/immutable/filenode.py @@ -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) diff --git a/src/allmydata/interfaces.py b/src/allmydata/interfaces.py index 80de5ef6..19f4b126 100644 --- a/src/allmydata/interfaces.py +++ b/src/allmydata/interfaces.py @@ -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. diff --git a/src/allmydata/test/test_dirnode.py b/src/allmydata/test/test_dirnode.py index 399f3989..4cd3163e 100644 --- a/src/allmydata/test/test_dirnode.py +++ b/src/allmydata/test/test_dirnode.py @@ -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, {})) diff --git a/src/allmydata/test/test_filenode.py b/src/allmydata/test/test_filenode.py index e1a4b17b..04cc68d1 100644 --- a/src/allmydata/test/test_filenode.py +++ b/src/allmydata/test/test_filenode.py @@ -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__ diff --git a/src/allmydata/test/test_mutable.py b/src/allmydata/test/test_mutable.py index 6abfe1bd..ca78bbb2 100644 --- a/src/allmydata/test/test_mutable.py +++ b/src/allmydata/test/test_mutable.py @@ -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)