From 5a3acc05b73095b80b5c102e03343a4a9489bfc2 Mon Sep 17 00:00:00 2001 From: david-sarah Date: Thu, 13 Jan 2011 20:03:27 -0800 Subject: [PATCH] CLI: tests for ref #1305 (v2, remove spurious extra arg to create-alias in test) --- src/allmydata/test/test_cli.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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) -- 2.45.2