1
0
mirror of https://github.com/certbot/certbot.git synced 2026-01-21 19:01:07 +03:00
Files
certbot/letsencrypt/client/tests/cli_test.py
2015-05-04 12:47:08 +00:00

36 lines
1015 B
Python

"""Tests for letsencrypt.client.cli."""
import itertools
import unittest
import mock
class CLITest(unittest.TestCase):
"""Tests for different commands."""
@classmethod
def _call(cls, args):
from letsencrypt.client import cli
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)))):
self._call(['plugins',] + list(args))
if __name__ == '__main__':
unittest.main()