]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
webish mkdir-p: added unit test
authorrobk-tahoe <robk-tahoe@allmydata.com>
Tue, 18 Mar 2008 20:11:08 +0000 (13:11 -0700)
committerrobk-tahoe <robk-tahoe@allmydata.com>
Tue, 18 Mar 2008 20:11:08 +0000 (13:11 -0700)
added a test for the simple mkdir-p hack I added yesterday

checks that mkdir-p can create a directory hierarchy, and that resubmitting
a request for the same path yields the existing dir's uri

src/allmydata/test/test_web.py

index 4b597d1a8faf2d5aec660d223072ffcc486a0747..5711af92589c1bd087b892b81c7475ce4418b099 100644 (file)
@@ -781,6 +781,25 @@ class Web(WebMixin, unittest.TestCase):
         d.addCallback(self.failUnlessNodeKeysAre, [u"baz.txt"])
         return d
 
+    def test_PUT_NEWDIRURL_mkdir_p(self):
+        d = defer.succeed(None)
+        d.addCallback(lambda res: self.POST(self.public_url + "/foo", t='mkdir', name='mkp'))
+        d.addCallback(lambda res: self.failUnlessNodeHasChild(self._foo_node, u"mkp"))
+        d.addCallback(lambda res: self._foo_node.get(u"mkp"))
+        def mkdir_p(mkpnode):
+            url = '/uri/%s?t=mkdir-p&path=/sub1/sub2' % urllib.quote(mkpnode.get_uri())
+            d = self.POST(url)
+            def made_subsub(ssuri):
+                d = self._foo_node.get_child_at_path(u"mkp/sub1/sub2")
+                d.addCallback(lambda ssnode: self.failUnlessEqual(ssnode.get_uri(), ssuri))
+                d = self.POST(url)
+                d.addCallback(lambda uri2: self.failUnlessEqual(uri2, ssuri))
+                return d
+            d.addCallback(made_subsub)
+            return d
+        d.addCallback(mkdir_p)
+        return d
+
     def test_PUT_NEWDIRURL_mkdirs(self):
         d = self.PUT(self.public_url + "/foo/subdir/newdir?t=mkdir", "")
         d.addCallback(lambda res: