]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
test_dirnode.py: add tests of initial_children= args to client.create_dirnode
authorBrian Warner <warner@lothar.com>
Sat, 17 Oct 2009 19:41:59 +0000 (12:41 -0700)
committerBrian Warner <warner@lothar.com>
Sat, 17 Oct 2009 19:41:59 +0000 (12:41 -0700)
and nodemaker.create_new_mutable_directory

src/allmydata/test/test_dirnode.py

index a4313dee7910506c7c1a98fb60b9765ec87557a6..aed7e9d76cad834f0dd5eed671b9655f0469980e 100644 (file)
@@ -36,6 +36,38 @@ class Dirnode(GridTestMixin, unittest.TestCase,
         d.addCallback(_done)
         return d
 
+    def test_initial_children(self):
+        self.basedir = "dirnode/Dirnode/test_initial_children"
+        self.set_up_grid()
+        c = self.g.clients[0]
+        setup_py_uri = "URI:CHK:n7r3m6wmomelk4sep3kw5cvduq:os7ijw5c3maek7pg65e5254k2fzjflavtpejjyhshpsxuqzhcwwq:3:20:14861"
+        one_uri = "URI:LIT:n5xgk" # LIT for "one"
+        kids = {u"one": (c.nodemaker.create_from_cap(one_uri), {}),
+                u"two": (c.nodemaker.create_from_cap(setup_py_uri),
+                         {"metakey": "metavalue"}),
+                }
+        d = c.create_dirnode(kids)
+        def _created(dn):
+            self.failUnless(isinstance(dn, dirnode.DirectoryNode))
+            rep = str(dn)
+            self.failUnless("RW" in rep)
+            return dn.list()
+        d.addCallback(_created)
+        def _check_kids(children):
+            self.failUnlessEqual(sorted(children.keys()), [u"one", u"two"])
+            one_node, one_metadata = children[u"one"]
+            two_node, two_metadata = children[u"two"]
+            self.failUnlessEqual(one_node.get_size(), 3)
+            self.failUnlessEqual(two_node.get_size(), 14861)
+            self.failUnless(isinstance(one_metadata, dict), one_metadata)
+            self.failUnlessEqual(two_metadata["metakey"], "metavalue")
+        d.addCallback(_check_kids)
+        d.addCallback(lambda ign:
+                      c.nodemaker.create_new_mutable_directory(kids))
+        d.addCallback(lambda dn: dn.list())
+        d.addCallback(_check_kids)
+        return d
+
     def test_check(self):
         self.basedir = "dirnode/Dirnode/test_check"
         self.set_up_grid()