Restore test coverage.
This commit is contained in:
parent
66160253e3
commit
d237dcab15
|
@ -1760,7 +1760,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||||
def test_PUT_NEWFILEURL_unlinked_bad_format(self):
|
def test_PUT_NEWFILEURL_unlinked_bad_format(self):
|
||||||
contents = self.NEWFILE_CONTENTS * 300000
|
contents = self.NEWFILE_CONTENTS * 300000
|
||||||
yield self.assertHTTPError(self.webish_url + "/uri?format=foo", 400,
|
yield self.assertHTTPError(self.webish_url + "/uri?format=foo", 400,
|
||||||
"Unknown format:",
|
"Unknown format: foo",
|
||||||
method="put", data=contents)
|
method="put", data=contents)
|
||||||
|
|
||||||
def test_PUT_NEWFILEURL_range_bad(self):
|
def test_PUT_NEWFILEURL_range_bad(self):
|
||||||
|
@ -1813,7 +1813,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||||
|
|
||||||
def test_PUT_NEWFILEURL_bad_t(self):
|
def test_PUT_NEWFILEURL_bad_t(self):
|
||||||
d = self.shouldFail2(error.Error, "PUT_bad_t", "400 Bad Request",
|
d = self.shouldFail2(error.Error, "PUT_bad_t", "400 Bad Request",
|
||||||
"PUT to a file: bad t=",
|
"PUT to a file: bad t=bogus",
|
||||||
self.PUT, self.public_url + "/foo/bar.txt?t=bogus",
|
self.PUT, self.public_url + "/foo/bar.txt?t=bogus",
|
||||||
b"contents")
|
b"contents")
|
||||||
return d
|
return d
|
||||||
|
@ -2344,7 +2344,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||||
def test_PUT_NEWDIRURL_bad_format(self):
|
def test_PUT_NEWDIRURL_bad_format(self):
|
||||||
url = (self.webish_url + self.public_url +
|
url = (self.webish_url + self.public_url +
|
||||||
"/foo/newdir=?t=mkdir&format=foo")
|
"/foo/newdir=?t=mkdir&format=foo")
|
||||||
yield self.assertHTTPError(url, 400, "Unknown format:",
|
yield self.assertHTTPError(url, 400, "Unknown format: foo",
|
||||||
method="put", data="")
|
method="put", data="")
|
||||||
|
|
||||||
def test_POST_NEWDIRURL(self):
|
def test_POST_NEWDIRURL(self):
|
||||||
|
@ -2377,7 +2377,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||||
def test_POST_NEWDIRURL_bad_format(self):
|
def test_POST_NEWDIRURL_bad_format(self):
|
||||||
url = (self.webish_url + self.public_url +
|
url = (self.webish_url + self.public_url +
|
||||||
"/foo/newdir?t=mkdir&format=foo")
|
"/foo/newdir?t=mkdir&format=foo")
|
||||||
yield self.assertHTTPError(url, 400, "Unknown format:",
|
yield self.assertHTTPError(url, 400, "Unknown format: foo",
|
||||||
method="post", data="")
|
method="post", data="")
|
||||||
|
|
||||||
def test_POST_NEWDIRURL_emptyname(self):
|
def test_POST_NEWDIRURL_emptyname(self):
|
||||||
|
@ -2454,7 +2454,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||||
(newkids, caps) = self._create_initial_children()
|
(newkids, caps) = self._create_initial_children()
|
||||||
url = (self.webish_url + self.public_url +
|
url = (self.webish_url + self.public_url +
|
||||||
"/foo/newdir?t=mkdir-with-children&format=foo")
|
"/foo/newdir?t=mkdir-with-children&format=foo")
|
||||||
yield self.assertHTTPError(url, 400, "Unknown format:",
|
yield self.assertHTTPError(url, 400, "Unknown format: foo",
|
||||||
method="post", data=json.dumps(newkids).encode("utf-8"))
|
method="post", data=json.dumps(newkids).encode("utf-8"))
|
||||||
|
|
||||||
def test_POST_NEWDIRURL_immutable(self):
|
def test_POST_NEWDIRURL_immutable(self):
|
||||||
|
@ -2578,7 +2578,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||||
def test_PUT_NEWDIRURL_mkdirs_bad_format(self):
|
def test_PUT_NEWDIRURL_mkdirs_bad_format(self):
|
||||||
url = (self.webish_url + self.public_url +
|
url = (self.webish_url + self.public_url +
|
||||||
"/foo/subdir/newdir?t=mkdir&format=foo")
|
"/foo/subdir/newdir?t=mkdir&format=foo")
|
||||||
yield self.assertHTTPError(url, 400, "Unknown format:",
|
yield self.assertHTTPError(url, 400, "Unknown format: foo",
|
||||||
method="put", data="")
|
method="put", data="")
|
||||||
|
|
||||||
def test_DELETE_DIRURL(self):
|
def test_DELETE_DIRURL(self):
|
||||||
|
@ -2857,7 +2857,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||||
url = self.webish_url + "/uri?t=upload&format=foo"
|
url = self.webish_url + "/uri?t=upload&format=foo"
|
||||||
body, headers = self.build_form(file=("foo.txt", self.NEWFILE_CONTENTS * 300000))
|
body, headers = self.build_form(file=("foo.txt", self.NEWFILE_CONTENTS * 300000))
|
||||||
yield self.assertHTTPError(url, 400,
|
yield self.assertHTTPError(url, 400,
|
||||||
"Unknown format:",
|
"Unknown format: foo",
|
||||||
method="post", data=body, headers=headers)
|
method="post", data=body, headers=headers)
|
||||||
|
|
||||||
def test_POST_upload_format(self):
|
def test_POST_upload_format(self):
|
||||||
|
@ -2892,7 +2892,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||||
def test_POST_upload_bad_format(self):
|
def test_POST_upload_bad_format(self):
|
||||||
url = self.webish_url + self.public_url + "/foo?t=upload&format=foo"
|
url = self.webish_url + self.public_url + "/foo?t=upload&format=foo"
|
||||||
body, headers = self.build_form(file=("foo.txt", self.NEWFILE_CONTENTS * 300000))
|
body, headers = self.build_form(file=("foo.txt", self.NEWFILE_CONTENTS * 300000))
|
||||||
yield self.assertHTTPError(url, 400, "Unknown format:",
|
yield self.assertHTTPError(url, 400, "Unknown format: foo",
|
||||||
method="post", data=body, headers=headers)
|
method="post", data=body, headers=headers)
|
||||||
|
|
||||||
def test_POST_upload_mutable(self):
|
def test_POST_upload_mutable(self):
|
||||||
|
@ -3388,7 +3388,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||||
def test_POST_mkdir_bad_format(self):
|
def test_POST_mkdir_bad_format(self):
|
||||||
url = (self.webish_url + self.public_url +
|
url = (self.webish_url + self.public_url +
|
||||||
"/foo?t=mkdir&name=newdir&format=foo")
|
"/foo?t=mkdir&name=newdir&format=foo")
|
||||||
yield self.assertHTTPError(url, 400, "Unknown format:",
|
yield self.assertHTTPError(url, 400, "Unknown format: foo",
|
||||||
method="post")
|
method="post")
|
||||||
|
|
||||||
def test_POST_mkdir_initial_children(self):
|
def test_POST_mkdir_initial_children(self):
|
||||||
|
@ -3440,7 +3440,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||||
(newkids, caps) = self._create_initial_children()
|
(newkids, caps) = self._create_initial_children()
|
||||||
url = (self.webish_url + self.public_url +
|
url = (self.webish_url + self.public_url +
|
||||||
"/foo?t=mkdir-with-children&name=newdir&format=foo")
|
"/foo?t=mkdir-with-children&name=newdir&format=foo")
|
||||||
yield self.assertHTTPError(url, 400, "Unknown format:",
|
yield self.assertHTTPError(url, 400, "Unknown format: foo",
|
||||||
method="post", data=json.dumps(newkids).encode("utf-8"))
|
method="post", data=json.dumps(newkids).encode("utf-8"))
|
||||||
|
|
||||||
def test_POST_mkdir_immutable(self):
|
def test_POST_mkdir_immutable(self):
|
||||||
|
@ -3519,7 +3519,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||||
@inlineCallbacks
|
@inlineCallbacks
|
||||||
def test_POST_mkdir_no_parentdir_noredirect_bad_format(self):
|
def test_POST_mkdir_no_parentdir_noredirect_bad_format(self):
|
||||||
url = self.webish_url + self.public_url + "/uri?t=mkdir&format=foo"
|
url = self.webish_url + self.public_url + "/uri?t=mkdir&format=foo"
|
||||||
yield self.assertHTTPError(url, 400, "Unknown format:",
|
yield self.assertHTTPError(url, 400, "Unknown format: foo",
|
||||||
method="post")
|
method="post")
|
||||||
|
|
||||||
def test_POST_mkdir_no_parentdir_noredirect2(self):
|
def test_POST_mkdir_no_parentdir_noredirect2(self):
|
||||||
|
@ -4462,7 +4462,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||||
def test_PUT_NEWFILEURL_bad_format(self):
|
def test_PUT_NEWFILEURL_bad_format(self):
|
||||||
new_contents = self.NEWFILE_CONTENTS * 300000
|
new_contents = self.NEWFILE_CONTENTS * 300000
|
||||||
url = self.webish_url + self.public_url + "/foo/foo.txt?format=foo"
|
url = self.webish_url + self.public_url + "/foo/foo.txt?format=foo"
|
||||||
yield self.assertHTTPError(url, 400, "Unknown format:",
|
yield self.assertHTTPError(url, 400, "Unknown format: foo",
|
||||||
method="put", data=new_contents)
|
method="put", data=new_contents)
|
||||||
|
|
||||||
def test_PUT_NEWFILEURL_uri_replace(self):
|
def test_PUT_NEWFILEURL_uri_replace(self):
|
||||||
|
@ -4595,7 +4595,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||||
@inlineCallbacks
|
@inlineCallbacks
|
||||||
def test_PUT_mkdir_bad_format(self):
|
def test_PUT_mkdir_bad_format(self):
|
||||||
url = self.webish_url + "/uri?t=mkdir&format=foo"
|
url = self.webish_url + "/uri?t=mkdir&format=foo"
|
||||||
yield self.assertHTTPError(url, 400, "Unknown format:",
|
yield self.assertHTTPError(url, 400, "Unknown format: foo",
|
||||||
method="put", data=b"")
|
method="put", data=b"")
|
||||||
|
|
||||||
def test_POST_check(self):
|
def test_POST_check(self):
|
||||||
|
|
|
@ -128,7 +128,7 @@ def get_format(req, default="CHK"):
|
||||||
elif arg.upper() == b"MDMF":
|
elif arg.upper() == b"MDMF":
|
||||||
return "MDMF"
|
return "MDMF"
|
||||||
else:
|
else:
|
||||||
raise WebError("Unknown format: %s, I know CHK, SDMF, MDMF" % arg,
|
raise WebError("Unknown format: %s, I know CHK, SDMF, MDMF" % ensure_str(arg),
|
||||||
http.BAD_REQUEST)
|
http.BAD_REQUEST)
|
||||||
|
|
||||||
def get_mutable_type(file_format): # accepts result of get_format()
|
def get_mutable_type(file_format): # accepts result of get_format()
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from past.builtins import unicode, long
|
from past.builtins import unicode, long
|
||||||
|
from six import ensure_str
|
||||||
|
|
||||||
from twisted.web import http, static
|
from twisted.web import http, static
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
@ -130,7 +131,7 @@ class PlaceHolderNodeHandler(Resource, ReplaceMeMixin):
|
||||||
if t == b"uri":
|
if t == b"uri":
|
||||||
return self.replace_me_with_a_childcap(req, self.client, replace)
|
return self.replace_me_with_a_childcap(req, self.client, replace)
|
||||||
|
|
||||||
raise WebError("PUT to a file: bad t=%s" % t)
|
raise WebError("PUT to a file: bad t=%s" % ensure_str(t))
|
||||||
|
|
||||||
@render_exception
|
@render_exception
|
||||||
def render_POST(self, req):
|
def render_POST(self, req):
|
||||||
|
@ -287,7 +288,7 @@ class FileNodeHandler(Resource, ReplaceMeMixin, object):
|
||||||
assert self.parentnode and self.name
|
assert self.parentnode and self.name
|
||||||
return self.replace_me_with_a_childcap(req, self.client, replace)
|
return self.replace_me_with_a_childcap(req, self.client, replace)
|
||||||
|
|
||||||
raise WebError("PUT to a file: bad t=%s" % t)
|
raise WebError("PUT to a file: bad t=%s" % ensure_str(t))
|
||||||
|
|
||||||
@render_exception
|
@render_exception
|
||||||
def render_POST(self, req):
|
def render_POST(self, req):
|
||||||
|
|
Loading…
Reference in New Issue