diff --git a/letsencrypt/client/tests/cli_test.py b/letsencrypt/client/tests/cli_test.py index bb50715e5..0b90953b1 100644 --- a/letsencrypt/client/tests/cli_test.py +++ b/letsencrypt/client/tests/cli_test.py @@ -1,11 +1,37 @@ +"""Tests for letsencrypt.client.cli.""" +import itertools +import sys import unittest +import mock +import zope.component + +from letsencrypt.client.display import util as display_util + class CLITest(unittest.TestCase): + """Tests for different commands.""" - def test_it(self): + def _call(self, args): from letsencrypt.client import cli - self.assertRaises(SystemExit, cli.main, ['--help']) + args = ['--text'] + args + with mock.patch("letsencrypt.client.cli.sys.stdout") as stdout: + with mock.patch("letsencrypt.client.cli.sys.stderr") as stderr: + ret = cli.main(args) + return ret, stdout, stderr + + def test_no_flags(self): + self.assertRaises(SystemExit, self._call, []) + + def test_help(self): + self.assertRaises(SystemExit, self._call, ['--help']) + + def test_plugins(self): + flags = ['--init', '--prepare', '--authenticators', '--installers'] + for args in itertools.chain(*(itertools.combinations(flags, r) + for r in xrange(len(flags)))): + print args + self._call(['plugins',] + list(args)) if __name__ == '__main__':