From: Brian Warner Date: Mon, 16 Jul 2007 19:01:19 +0000 (-0700) Subject: webish: test error cases more thoroughly by looking inside the response text X-Git-Url: https://git.rkrishnan.org/pf/content/en/footer/FOOURL?a=commitdiff_plain;h=56dcb814a8186c51eef60efe9b2ad30c02e1cd92;p=tahoe-lafs%2Ftahoe-lafs.git webish: test error cases more thoroughly by looking inside the response text --- diff --git a/src/allmydata/test/test_web.py b/src/allmydata/test/test_web.py index e31f8efe..d8914b0f 100644 --- a/src/allmydata/test/test_web.py +++ b/src/allmydata/test/test_web.py @@ -387,7 +387,8 @@ class Web(unittest.TestCase): d = self.PUT("/vdrive/global/foo/blockingfile/new.txt", self.NEWFILE_CONTENTS) d.addBoth(self.shouldFail, error.Error, "PUT_NEWFILEURL_blocked", - "403 Forbidden") + "400 Bad Request", + "cannot create directory because there is a file in the way") return d def test_DELETE_FILEURL(self): # YES @@ -444,7 +445,8 @@ class Web(unittest.TestCase): d = self.GET("/vdrive/global/foo/bar.txt?t=download&localfile=%s" % localfile) d.addBoth(self.shouldFail, error.Error, "localfile non-local", - "403 Forbidden") + "403 Forbidden", + "localfile= or localdir= requires a local connection") def _check(res): self.failIf(os.path.exists(localfile)) d.addCallback(_check) @@ -460,7 +462,8 @@ class Web(unittest.TestCase): d = self.GET("/vdrive/global/foo/bar.txt?t=download&localfile=%s" % localfile) d.addBoth(self.shouldFail, error.Error, "localfile non-absolute", - "403 Forbidden") + "403 Forbidden", + "localfile= or localdir= requires an absolute path") def _check(res): self.failIf(os.path.exists(localfile)) d.addCallback(_check) diff --git a/src/allmydata/webish.py b/src/allmydata/webish.py index 6ec7a5e8..eba44991 100644 --- a/src/allmydata/webish.py +++ b/src/allmydata/webish.py @@ -626,15 +626,18 @@ class PUTHandler(rend.Page): d.addCallback(self._upload_file, req.content, name) def _check_blocking(f): f.trap(BlockingFileError) - req.setResponseCode(http.FORBIDDEN) + req.setResponseCode(http.BAD_REQUEST) req.setHeader("content-type", "text/plain") - return str(f) + return str(f.value) d.addErrback(_check_blocking) return d def _get_or_create_directories(self, node, path): if not IDirectoryNode.providedBy(node): - raise BlockingFileError + # unfortunately it is too late to provide the name of the + # blocking directory in the error message. + raise BlockingFileError("cannot create directory because there " + "is a file in the way") if not path: return defer.succeed(node) d = node.get(path[0])