From: Brian Warner Date: Sat, 17 Oct 2009 19:41:59 +0000 (-0700) Subject: test_dirnode.py: add tests of initial_children= args to client.create_dirnode X-Git-Tag: trac-4100~11 X-Git-Url: https://git.rkrishnan.org/frontends/listings/pb1server.py?a=commitdiff_plain;h=59ee02e82f0bacc0aec3d85ddd81a48fff2b881c;p=tahoe-lafs%2Ftahoe-lafs.git test_dirnode.py: add tests of initial_children= args to client.create_dirnode and nodemaker.create_new_mutable_directory --- diff --git a/src/allmydata/test/test_dirnode.py b/src/allmydata/test/test_dirnode.py index a4313dee..aed7e9d7 100644 --- a/src/allmydata/test/test_dirnode.py +++ b/src/allmydata/test/test_dirnode.py @@ -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()