From: Brian Warner Date: Fri, 24 Oct 2008 00:11:18 +0000 (-0700) Subject: test_web: more test coverage X-Git-Url: https://git.rkrishnan.org/module-simplejson.tests.html?a=commitdiff_plain;h=cadb045288927b2c429b04a8c52986fa91ff2d2d;p=tahoe-lafs%2Ftahoe-lafs.git test_web: more test coverage --- diff --git a/src/allmydata/test/common.py b/src/allmydata/test/common.py index b3659407..b40c1fc5 100644 --- a/src/allmydata/test/common.py +++ b/src/allmydata/test/common.py @@ -57,6 +57,7 @@ class FakeCHKFileNode: nodeid = "\x00"*20 data["list-corrupt-shares"] = [] data["sharemap"] = {1: [nodeid]} + data["servers-responding"] = [nodeid] data["count-recoverable-versions"] = 1 data["count-unrecoverable-versions"] = 0 if is_bad: @@ -173,6 +174,7 @@ class FakeMutableFileNode: data["list-corrupt-shares"] = [] nodeid = "\x00"*20 data["sharemap"] = {"seq1-abcd-sh0": [nodeid]} + data["servers-responding"] = [nodeid] data["count-recoverable-versions"] = 1 data["count-unrecoverable-versions"] = 0 if is_bad: diff --git a/src/allmydata/test/test_web.py b/src/allmydata/test/test_web.py index d3181ba8..c99d2af0 100644 --- a/src/allmydata/test/test_web.py +++ b/src/allmydata/test/test_web.py @@ -8,7 +8,7 @@ from twisted.python import failure, log from allmydata import interfaces, provisioning, uri, webish from allmydata.immutable import upload, download from allmydata.web import status, common -from allmydata.util import fileutil, testutil +from allmydata.util import fileutil, testutil, base32 from allmydata.test.common import FakeDirectoryNode, FakeCHKFileNode, \ FakeMutableFileNode, create_chk_filenode from allmydata.interfaces import IURI, INewDirectoryURI, \ @@ -1492,6 +1492,15 @@ class Web(WebMixin, testutil.StallMixin, unittest.TestCase): self.failUnless("Return to parent directory" in res) self.failUnless(redir_url in res) d.addCallback(_check3) + + d.addCallback(lambda res: + self.POST(bar_url, t="check", output="JSON")) + def _check_json(res): + data = simplejson.loads(res) + self.failUnless("storage-index" in data) + self.failUnless(data["results"]["healthy"]) + d.addCallback(_check_json) + return d def test_POST_FILEURL_check_and_repair(self): @@ -1542,6 +1551,15 @@ class Web(WebMixin, testutil.StallMixin, unittest.TestCase): self.failUnless("Return to parent directory" in res) self.failUnless(redir_url in res) d.addCallback(_check3) + + d.addCallback(lambda res: + self.POST(foo_url, t="check", output="JSON")) + def _check_json(res): + data = simplejson.loads(res) + self.failUnless("storage-index" in data) + self.failUnless(data["results"]["healthy"]) + d.addCallback(_check_json) + return d def test_POST_DIRURL_check_and_repair(self): @@ -1622,6 +1640,19 @@ class Web(WebMixin, testutil.StallMixin, unittest.TestCase): self.failUnless("Objects Checked: 8" in res) self.failUnless("Objects Healthy: 8" in res) d.addCallback(_check_html) + d.addCallback(lambda res: + self.shouldFail2(error.Error, "one", "404 Not Found", + "No detailed results for SI bogus", + self.GET, "/operations/123/bogus")) + foo_si = self._foo_node.get_storage_index() + foo_si_s = base32.b2a(foo_si) + d.addCallback(lambda res: + self.GET("/operations/123/%s?output=JSON" % foo_si_s)) + def _check_foo_json(res): + data = simplejson.loads(res) + self.failUnlessEqual(data["storage-index"], foo_si_s) + self.failUnless(data["results"]["healthy"]) + d.addCallback(_check_foo_json) return d def test_POST_DIRURL_deepcheck_and_repair(self):