]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
mutable: minor refactoring of _do_read, to make other tests easier
authorBrian Warner <warner@allmydata.com>
Mon, 10 Mar 2008 22:42:56 +0000 (15:42 -0700)
committerBrian Warner <warner@allmydata.com>
Mon, 10 Mar 2008 22:42:56 +0000 (15:42 -0700)
src/allmydata/mutable.py
src/allmydata/test/test_mutable.py

index 8d861ea6680abafadf22ccafc013ded6d63b8d50..c57e5d695df183268a144d9ba669d91d908b15f9 100644 (file)
@@ -1098,10 +1098,15 @@ class Publish:
         # the permuted peerlist.
         return d
 
+    def _do_read(self, ss, peerid, storage_index, shnums, readv):
+        # isolate the callRemote to a separate method, so tests can subclass
+        # Publish and override it
+        d = ss.callRemote("slot_readv", storage_index, shnums, readv)
+        return d
+
     def _do_query(self, ss, peerid, storage_index):
         self.log("querying %s" % idlib.shortnodeid_b2a(peerid))
-        d = ss.callRemote("slot_readv",
-                          storage_index, [], [(0, self._read_size)])
+        d = self._do_read(ss, peerid, storage_index, [], [(0, self._read_size)])
         return d
 
     def _got_query_results(self, datavs, peerid, permutedid,
@@ -1302,8 +1307,8 @@ class Publish:
 
     def _do_privkey_query(self, rref, peerid, shnum, offset, length):
         started = time.time()
-        d = rref.callRemote("slot_readv", self._storage_index,
-                            [shnum], [(offset, length)] )
+        d = self._do_read(rref, peerid, self._storage_index,
+                          [shnum], [(offset, length)])
         d.addCallback(self._privkey_query_response, peerid, shnum, started)
         return d
 
index bc6403666e0c713cf4f2a12dcfd61247ed9d6d53..184698364066b452f22cd25255ac8fb9b79c0ae5 100644 (file)
@@ -47,8 +47,9 @@ class FakeFilenode(mutable.MutableFileNode):
         return defer.succeed(None)
 
 class FakePublish(mutable.Publish):
-    def _do_query(self, ss, peerid, storage_index):
+    def _do_read(self, ss, peerid, storage_index, shnums, readv):
         assert ss[0] == peerid
+        assert shnums == []
         shares = self._peers[peerid]
         return defer.succeed(shares)
 
@@ -275,6 +276,7 @@ class Publish(unittest.TestCase):
         p = FakePublish(fn)
         p._storage_index = "\x00"*32
         p._new_seqnum = 3
+        p._read_size = 1000
         #r = mutable.Retrieve(fn)
         p._peers = {}
         for peerid in c._peerids: