From: david-sarah Date: Fri, 14 Jan 2011 04:03:27 +0000 (-0800) Subject: CLI: tests for ref #1305 (v2, remove spurious extra arg to create-alias in test) X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/flags/index.php?a=commitdiff_plain;h=5a3acc05b73095b80b5c102e03343a4a9489bfc2;p=tahoe-lafs%2Ftahoe-lafs.git CLI: tests for ref #1305 (v2, remove spurious extra arg to create-alias in test) --- diff --git a/src/allmydata/test/test_cli.py b/src/allmydata/test/test_cli.py index 16a2ab9d..560c6759 100644 --- a/src/allmydata/test/test_cli.py +++ b/src/allmydata/test/test_cli.py @@ -498,11 +498,11 @@ class Help(unittest.TestCase): def test_create_alias(self): help = str(cli.CreateAliasOptions()) - self.failUnless("create-alias ALIAS" in help, help) + self.failUnless("create-alias ALIAS[:]" in help, help) def test_add_aliases(self): help = str(cli.AddAliasOptions()) - self.failUnless("add-alias ALIAS DIRCAP" in help, help) + self.failUnless("add-alias ALIAS[:] DIRCAP" in help, help) class CreateAlias(GridTestMixin, CLITestMixin, unittest.TestCase): @@ -530,7 +530,7 @@ class CreateAlias(GridTestMixin, CLITestMixin, unittest.TestCase): self.failUnless("tahoe" in aliases) self.failUnless(aliases["tahoe"].startswith("URI:DIR2:")) d.addCallback(_done) - d.addCallback(lambda res: self.do_cli("create-alias", "two")) + d.addCallback(lambda res: self.do_cli("create-alias", "two:")) def _stash_urls(res): aliases = get_aliases(self.get_clientdir()) @@ -567,6 +567,17 @@ class CreateAlias(GridTestMixin, CLITestMixin, unittest.TestCase): self.failUnlessReallyEqual(aliases["two"], self.two_uri) d.addCallback(_check_add_duplicate) + # check create-alias and add-alias with invalid aliases + def _check_invalid((rc,stdout,stderr)): + self.failIfEqual(rc, 0) + self.failUnlessIn("cannot contain", stderr) + + for invalid in ['foo:bar', 'foo bar', 'foobar::']: + d.addCallback(lambda res: self.do_cli("create-alias", invalid)) + d.addCallback(_check_invalid) + d.addCallback(lambda res: self.do_cli("add-alias", invalid, self.two_uri)) + d.addCallback(_check_invalid) + def _test_urls(junk): self._test_webopen([], self.welcome_url) self._test_webopen(["/"], self.tahoe_url)