]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
webish: test error cases more thoroughly by looking inside the response text
authorBrian Warner <warner@allmydata.com>
Mon, 16 Jul 2007 19:01:19 +0000 (12:01 -0700)
committerBrian Warner <warner@allmydata.com>
Mon, 16 Jul 2007 19:01:19 +0000 (12:01 -0700)
src/allmydata/test/test_web.py
src/allmydata/webish.py

index e31f8efe522ccc0722d39bcad085a4e7da9c5b30..d8914b0fa0110739c436a33999c7d755b713fcd7 100644 (file)
@@ -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)
index 6ec7a5e8de5cd97ab20a30c57fcf1d1c11beaa23..eba44991d73fe6f107e660205e843ba2ff3068d1 100644 (file)
@@ -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])