From: Kevan Carstensen Date: Wed, 4 Nov 2009 12:13:24 +0000 (-0700) Subject: Add a test for upload.shares_by_server X-Git-Url: https://git.rkrishnan.org/pf/content/%22file:/frontends/somewhere?a=commitdiff_plain;h=697f1cfae8ee6c6afe010cb0bffd6183600bbc8e;p=tahoe-lafs%2Ftahoe-lafs.git Add a test for upload.shares_by_server --- diff --git a/src/allmydata/test/test_upload.py b/src/allmydata/test/test_upload.py index e0125a69..b58e6035 100644 --- a/src/allmydata/test/test_upload.py +++ b/src/allmydata/test/test_upload.py @@ -1010,6 +1010,30 @@ class EncodingParameters(GridTestMixin, unittest.TestCase, SetDEPMixin, self.failUnlessIn(server, unique_servers) + def test_shares_by_server(self): + test = { + 1 : "server1", + 2 : "server2", + 3 : "server3", + 4 : "server4" + } + shares_by_server = upload.shares_by_server(test) + self.failUnlessEqual(set([1]), shares_by_server["server1"]) + self.failUnlessEqual(set([2]), shares_by_server["server2"]) + self.failUnlessEqual(set([3]), shares_by_server["server3"]) + self.failUnlessEqual(set([4]), shares_by_server["server4"]) + test1 = { + 1 : "server1", + 2 : "server1", + 3 : "server1", + 4 : "server2", + 5 : "server2" + } + shares_by_server = upload.shares_by_server(test1) + self.failUnlessEqual(set([1, 2, 3]), shares_by_server["server1"]) + self.failUnlessEqual(set([4, 5]), shares_by_server["server2"]) + + def _set_up_nodes_extra_config(self, clientdir): cfgfn = os.path.join(clientdir, "tahoe.cfg") oldcfg = open(cfgfn, "r").read()