mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-06-06 09:31:43 +00:00
web: even more test coverage
This commit is contained in:
parent
2eadabbf82
commit
6b51841ec8
@ -521,6 +521,28 @@ class Web(WebMixin, unittest.TestCase):
|
|||||||
self.GET, base)
|
self.GET, base)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def test_GET_FILE_URI(self):
|
||||||
|
base = "/uri/%s" % urllib.quote(self._bar_txt_uri)
|
||||||
|
d = self.GET(base)
|
||||||
|
d.addCallback(self.failUnlessIsBarDotTxt)
|
||||||
|
return d
|
||||||
|
|
||||||
|
def test_GET_FILE_URI_badchild(self):
|
||||||
|
base = "/uri/%s/boguschild" % urllib.quote(self._bar_txt_uri)
|
||||||
|
errmsg = "Files have no children, certainly not named 'boguschild'"
|
||||||
|
d = self.shouldFail2(error.Error, "test_GET_FILE_URI_badchild",
|
||||||
|
"400 Bad Request", errmsg,
|
||||||
|
self.GET, base)
|
||||||
|
return d
|
||||||
|
|
||||||
|
def test_PUT_FILE_URI_badchild(self):
|
||||||
|
base = "/uri/%s/boguschild" % urllib.quote(self._bar_txt_uri)
|
||||||
|
errmsg = "Cannot create directory 'boguschild', because its parent is a file, not a directory"
|
||||||
|
d = self.shouldFail2(error.Error, "test_GET_FILE_URI_badchild",
|
||||||
|
"400 Bad Request", errmsg,
|
||||||
|
self.PUT, base, "")
|
||||||
|
return d
|
||||||
|
|
||||||
def test_GET_FILEURL_save(self):
|
def test_GET_FILEURL_save(self):
|
||||||
d = self.GET(self.public_url + "/foo/bar.txt?filename=bar.txt&save=true")
|
d = self.GET(self.public_url + "/foo/bar.txt?filename=bar.txt&save=true")
|
||||||
# TODO: look at the headers, expect a Content-Disposition: attachment
|
# TODO: look at the headers, expect a Content-Disposition: attachment
|
||||||
@ -1092,6 +1114,17 @@ class Web(WebMixin, unittest.TestCase):
|
|||||||
self.failUnlessEqual(new_json[1]["ro_uri"], ro_uri)
|
self.failUnlessEqual(new_json[1]["ro_uri"], ro_uri)
|
||||||
d.addCallback(_check_page_json)
|
d.addCallback(_check_page_json)
|
||||||
|
|
||||||
|
# and look at t=uri and t=readonly-uri
|
||||||
|
d.addCallback(lambda res:
|
||||||
|
self.GET(self.public_url + "/foo/new.txt?t=uri"))
|
||||||
|
d.addCallback(lambda res: self.failUnlessEqual(res, self._mutable_uri))
|
||||||
|
d.addCallback(lambda res:
|
||||||
|
self.GET(self.public_url + "/foo/new.txt?t=readonly-uri"))
|
||||||
|
def _check_ro_uri(res):
|
||||||
|
ro_uri = unicode(self._mutable_node.get_readonly().to_string())
|
||||||
|
self.failUnlessEqual(res, ro_uri)
|
||||||
|
d.addCallback(_check_ro_uri)
|
||||||
|
|
||||||
d.addErrback(self.dump_error)
|
d.addErrback(self.dump_error)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@ -1185,6 +1218,22 @@ class Web(WebMixin, unittest.TestCase):
|
|||||||
u"sub"]))
|
u"sub"]))
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def test_POST_FILEURL_check(self):
|
||||||
|
d = self.POST(self.public_url + "/foo/bar.txt", t="check")
|
||||||
|
def _check(res):
|
||||||
|
# this currently just returns "None". You'd only really use it
|
||||||
|
# with a when_done= redirect.
|
||||||
|
self.failUnlessEqual(res, "None")
|
||||||
|
d.addCallback(_check)
|
||||||
|
return d
|
||||||
|
|
||||||
|
def test_POST_FILEURL_bad_t(self):
|
||||||
|
d = self.shouldFail2(error.Error, "POST_bad_t", "400 Bad Request",
|
||||||
|
"POST to file: bad t=bogus",
|
||||||
|
self.POST, self.public_url + "/foo/bar.txt",
|
||||||
|
t="bogus")
|
||||||
|
return d
|
||||||
|
|
||||||
def test_POST_mkdir(self): # return value?
|
def test_POST_mkdir(self): # return value?
|
||||||
d = self.POST(self.public_url + "/foo", t="mkdir", name="newdir")
|
d = self.POST(self.public_url + "/foo", t="mkdir", name="newdir")
|
||||||
d.addCallback(lambda res: self._foo_node.get(u"newdir"))
|
d.addCallback(lambda res: self._foo_node.get(u"newdir"))
|
||||||
|
@ -368,7 +368,7 @@ def FileURI(ctx, filenode):
|
|||||||
def FileReadOnlyURI(ctx, filenode):
|
def FileReadOnlyURI(ctx, filenode):
|
||||||
if filenode.is_readonly():
|
if filenode.is_readonly():
|
||||||
return text_plain(filenode.get_uri(), ctx)
|
return text_plain(filenode.get_uri(), ctx)
|
||||||
return text_plain(filenode.get_readonly().get_uri(), ctx)
|
return text_plain(filenode.get_readonly_uri(), ctx)
|
||||||
|
|
||||||
class FileNodeDownloadHandler(FileNodeHandler):
|
class FileNodeDownloadHandler(FileNodeHandler):
|
||||||
def childFactory(self, ctx, name):
|
def childFactory(self, ctx, name):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user