]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
web: improve test coverage, remove some dead code
authorBrian Warner <warner@allmydata.com>
Tue, 20 May 2008 18:13:12 +0000 (11:13 -0700)
committerBrian Warner <warner@allmydata.com>
Tue, 20 May 2008 18:13:12 +0000 (11:13 -0700)
src/allmydata/test/test_web.py
src/allmydata/web/directory.py
src/allmydata/web/filenode.py

index b97fdf29ea9dfb9ca72c3b89d54169884ac54653..a78b339e8bafeaf3b122b5c79241832b34b0f056 100644 (file)
@@ -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):
index 8e7c021acbd4a9c18cd65d54f12e98447ae3870b..55dec9c7926db8c1dea313264ed3045c9ac80a8d 100644 (file)
@@ -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
index 4710d504bb3049ff4e9d32068a071779cee27da4..6d09e13e4da895dec3e7fdd93fb4fa92276d77db 100644 (file)
@@ -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)