From df90dd8e73d44c2ef3e4194ec0ed9d2c752d4861 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Sun, 15 Feb 2009 21:04:51 -0700 Subject: [PATCH] test_cli: improve test coverage slightly --- src/allmydata/test/test_cli.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/allmydata/test/test_cli.py b/src/allmydata/test/test_cli.py index da940bd7..1ee4b9f2 100644 --- a/src/allmydata/test/test_cli.py +++ b/src/allmydata/test/test_cli.py @@ -20,6 +20,7 @@ from allmydata.scripts import cli, debug, runner, backupdb from allmydata.test.common import SystemTestMixin from allmydata.test.common_util import StallMixin from twisted.internet import threads # CLI tests use deferToThread +from twisted.python import usage class CLI(unittest.TestCase): # this test case only looks at argument-processing and simple stuff. @@ -69,6 +70,17 @@ class CLI(unittest.TestCase): self.failUnlessEqual(o.aliases[DEFAULT_ALIAS], other_uri) self.failUnlessEqual(o.where, "subdir") + o = cli.ListOptions() + self.failUnlessRaises(usage.UsageError, + o.parseOptions, + ["--node-directory", "cli/test_options", + "--node-url", "NOT-A-URL"]) + + o = cli.ListOptions() + o.parseOptions(["--node-directory", "cli/test_options", + "--node-url", "http://localhost:8080"]) + self.failUnlessEqual(o["node-url"], "http://localhost:8080/") + def _dump_cap(self, *args): config = debug.DumpCapOptions() config.stdout,config.stderr = StringIO(), StringIO() @@ -575,6 +587,11 @@ class Put(SystemTestMixin, CLITestMixin, unittest.TestCase): return d class Cp(SystemTestMixin, CLITestMixin, unittest.TestCase): + def test_not_enough_args(self): + o = cli.CpOptions() + self.failUnlessRaises(usage.UsageError, + o.parseOptions, ["onearg"]) + def test_unicode_filename(self): self.basedir = os.path.dirname(self.mktemp()) -- 2.45.2