mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-07 11:50:21 +00:00
webish: test error cases more thoroughly by looking inside the response text
This commit is contained in:
parent
3f294d5597
commit
56dcb814a8
@ -387,7 +387,8 @@ class Web(unittest.TestCase):
|
|||||||
d = self.PUT("/vdrive/global/foo/blockingfile/new.txt",
|
d = self.PUT("/vdrive/global/foo/blockingfile/new.txt",
|
||||||
self.NEWFILE_CONTENTS)
|
self.NEWFILE_CONTENTS)
|
||||||
d.addBoth(self.shouldFail, error.Error, "PUT_NEWFILEURL_blocked",
|
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
|
return d
|
||||||
|
|
||||||
def test_DELETE_FILEURL(self): # YES
|
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"
|
d = self.GET("/vdrive/global/foo/bar.txt?t=download&localfile=%s"
|
||||||
% localfile)
|
% localfile)
|
||||||
d.addBoth(self.shouldFail, error.Error, "localfile non-local",
|
d.addBoth(self.shouldFail, error.Error, "localfile non-local",
|
||||||
"403 Forbidden")
|
"403 Forbidden",
|
||||||
|
"localfile= or localdir= requires a local connection")
|
||||||
def _check(res):
|
def _check(res):
|
||||||
self.failIf(os.path.exists(localfile))
|
self.failIf(os.path.exists(localfile))
|
||||||
d.addCallback(_check)
|
d.addCallback(_check)
|
||||||
@ -460,7 +462,8 @@ class Web(unittest.TestCase):
|
|||||||
d = self.GET("/vdrive/global/foo/bar.txt?t=download&localfile=%s"
|
d = self.GET("/vdrive/global/foo/bar.txt?t=download&localfile=%s"
|
||||||
% localfile)
|
% localfile)
|
||||||
d.addBoth(self.shouldFail, error.Error, "localfile non-absolute",
|
d.addBoth(self.shouldFail, error.Error, "localfile non-absolute",
|
||||||
"403 Forbidden")
|
"403 Forbidden",
|
||||||
|
"localfile= or localdir= requires an absolute path")
|
||||||
def _check(res):
|
def _check(res):
|
||||||
self.failIf(os.path.exists(localfile))
|
self.failIf(os.path.exists(localfile))
|
||||||
d.addCallback(_check)
|
d.addCallback(_check)
|
||||||
|
@ -626,15 +626,18 @@ class PUTHandler(rend.Page):
|
|||||||
d.addCallback(self._upload_file, req.content, name)
|
d.addCallback(self._upload_file, req.content, name)
|
||||||
def _check_blocking(f):
|
def _check_blocking(f):
|
||||||
f.trap(BlockingFileError)
|
f.trap(BlockingFileError)
|
||||||
req.setResponseCode(http.FORBIDDEN)
|
req.setResponseCode(http.BAD_REQUEST)
|
||||||
req.setHeader("content-type", "text/plain")
|
req.setHeader("content-type", "text/plain")
|
||||||
return str(f)
|
return str(f.value)
|
||||||
d.addErrback(_check_blocking)
|
d.addErrback(_check_blocking)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def _get_or_create_directories(self, node, path):
|
def _get_or_create_directories(self, node, path):
|
||||||
if not IDirectoryNode.providedBy(node):
|
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:
|
if not path:
|
||||||
return defer.succeed(node)
|
return defer.succeed(node)
|
||||||
d = node.get(path[0])
|
d = node.get(path[0])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user