From: david-sarah Date: Tue, 6 Sep 2011 18:30:20 +0000 (-0700) Subject: CLI: improve test for 'tahoe mkdir --mutable-type='. refs #1527 X-Git-Tag: allmydata-tahoe-1.9.0a2~59 X-Git-Url: https://git.rkrishnan.org/Site/Content/Exhibitors/install-details.html?a=commitdiff_plain;h=1e59930fda64428fce438f06dde733579c9902d0;p=tahoe-lafs%2Ftahoe-lafs.git CLI: improve test for 'tahoe mkdir --mutable-type='. refs #1527 --- diff --git a/src/allmydata/test/test_cli.py b/src/allmydata/test/test_cli.py index 9a60c5fd..d2b503eb 100644 --- a/src/allmydata/test/test_cli.py +++ b/src/allmydata/test/test_cli.py @@ -3308,29 +3308,24 @@ class Mkdir(GridTestMixin, CLITestMixin, unittest.TestCase): self.failUnlessReallyEqual(err, "") self.failUnlessIn(st, out) return out - def _stash_dircap(cap): - self._dircap = cap - u = uri.from_string(cap) - fn_uri = u.get_filenode_cap() - self._filecap = fn_uri.to_string() - d.addCallback(_check, "URI:DIR2") - d.addCallback(_stash_dircap) - d.addCallback(lambda ignored: - self.do_cli("ls", "--json", "tahoe:foo")) - d.addCallback(_check, "URI:DIR2") - d.addCallback(lambda ignored: - self.do_cli("ls", "--json", self._filecap)) - d.addCallback(_check, '"mutable-type": "sdmf"') - d.addCallback(lambda ignored: - self.do_cli("mkdir", "--mutable-type=MDMF", "tahoe:bar")) - d.addCallback(_check, "URI:DIR2-MDMF") - d.addCallback(_stash_dircap) - d.addCallback(lambda ignored: - self.do_cli("ls", "--json", "tahoe:bar")) - d.addCallback(_check, "URI:DIR2-MDMF") - d.addCallback(lambda ignored: - self.do_cli("ls", "--json", self._filecap)) - d.addCallback(_check, '"mutable-type": "mdmf"') + def _mkdir(ign, mutable_type, uri_prefix, dirname): + d2 = self.do_cli("mkdir", "--mutable-type="+mutable_type, dirname) + d2.addCallback(_check, uri_prefix) + def _stash_filecap(cap): + u = uri.from_string(cap) + fn_uri = u.get_filenode_cap() + self._filecap = fn_uri.to_string() + d2.addCallback(_stash_filecap) + d2.addCallback(lambda ign: self.do_cli("ls", "--json", dirname)) + d2.addCallback(_check, uri_prefix) + d2.addCallback(lambda ign: self.do_cli("ls", "--json", self._filecap)) + d2.addCallback(_check, '"mutable-type": "%s"' % (mutable_type.lower(),)) + return d2 + + d.addCallback(_mkdir, "sdmf", "URI:DIR2", "tahoe:foo") + d.addCallback(_mkdir, "SDMF", "URI:DIR2", "tahoe:foo2") + d.addCallback(_mkdir, "mdmf", "URI:DIR2-MDMF", "tahoe:bar") + d.addCallback(_mkdir, "MDMF", "URI:DIR2-MDMF", "tahoe:bar2") return d def test_mkdir_mutable_type_unlinked(self):