From 2eadabbf82d6e11019eb76157017f435ebbe1759 Mon Sep 17 00:00:00 2001 From: Brian Warner <warner@allmydata.com> Date: Tue, 20 May 2008 11:13:12 -0700 Subject: [PATCH] web: improve test coverage, remove some dead code --- src/allmydata/test/test_web.py | 3 +++ src/allmydata/web/directory.py | 2 +- src/allmydata/web/filenode.py | 9 ++++----- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/allmydata/test/test_web.py b/src/allmydata/test/test_web.py index b97fdf29..a78b339e 100644 --- a/src/allmydata/test/test_web.py +++ b/src/allmydata/test/test_web.py @@ -465,12 +465,15 @@ class Web(WebMixin, unittest.TestCase): def test_GET_FILEURL_named(self): base = "/file/%s" % urllib.quote(self._bar_txt_uri) + base2 = "/named/%s" % urllib.quote(self._bar_txt_uri) d = self.GET(base + "/@@name=/blah.txt") d.addCallback(self.failUnlessIsBarDotTxt) d.addCallback(lambda res: self.GET(base + "/blah.txt")) d.addCallback(self.failUnlessIsBarDotTxt) d.addCallback(lambda res: self.GET(base + "/ignore/lots/blah.txt")) d.addCallback(self.failUnlessIsBarDotTxt) + d.addCallback(lambda res: self.GET(base2 + "/@@name=/blah.txt")) + d.addCallback(self.failUnlessIsBarDotTxt) return d def test_PUT_FILEURL_named_bad(self): diff --git a/src/allmydata/web/directory.py b/src/allmydata/web/directory.py index 8e7c021a..55dec9c7 100644 --- a/src/allmydata/web/directory.py +++ b/src/allmydata/web/directory.py @@ -256,7 +256,7 @@ class DirectoryNodeHandler(RenderMixin, rend.Page, ReplaceMeMixin): if isinstance(node_or_failure, Failure): f = node_or_failure f.trap(KeyError) - # create a placeholder + # create a placeholder which will see POST t=upload return PlaceHolderNodeHandler(self.node, name) else: node = node_or_failure diff --git a/src/allmydata/web/filenode.py b/src/allmydata/web/filenode.py index 4710d504..6d09e13e 100644 --- a/src/allmydata/web/filenode.py +++ b/src/allmydata/web/filenode.py @@ -103,11 +103,7 @@ class PlaceHolderNodeHandler(RenderMixin, rend.Page, ReplaceMeMixin): req = IRequest(ctx) t = get_arg(req, "t", "").strip() replace = boolean_of_arg(get_arg(req, "replace", "true")) - if t == "mkdir": - d = self.parentnode.create_empty_directory(self.name, replace) - d.addCallback(lambda node: node.get_uri()) - d.addCallback(text_plain, ctx) - elif t == "upload": + if t == "upload": # like PUT, but get the file data from an HTML form's input field. # We could get here from POST /uri/mutablefilecap?t=upload, # or POST /uri/path/file?t=upload, or @@ -115,6 +111,9 @@ class PlaceHolderNodeHandler(RenderMixin, rend.Page, ReplaceMeMixin): # behavior, we just ignore any name= argument d = self.replace_me_with_a_formpost(ctx, replace) else: + # t=mkdir is handled in DirectoryNodeHandler._POST_mkdir, so + # there are no other t= values left to be handled by the + # placeholder. raise WebError("POST to a file: bad t=%s" % t) when_done = get_arg(req, "when_done", None) -- 2.45.2