mirror of
https://github.com/certbot/certbot.git
synced 2026-06-09 00:32:12 -04:00
More tests for cli.py
This commit is contained in:
parent
82bd808ab3
commit
0bc5791a55
1 changed files with 17 additions and 4 deletions
|
|
@ -12,10 +12,11 @@ class CLITest(unittest.TestCase):
|
|||
def _call(cls, args):
|
||||
from letsencrypt import cli
|
||||
args = ['--text'] + args
|
||||
with mock.patch("letsencrypt.cli.sys.stdout") as stdout:
|
||||
with mock.patch("letsencrypt.cli.sys.stderr") as stderr:
|
||||
ret = cli.main(args)
|
||||
return ret, stdout, stderr
|
||||
with mock.patch('letsencrypt.cli.sys.stdout') as stdout:
|
||||
with mock.patch('letsencrypt.cli.sys.stderr') as stderr:
|
||||
with mock.patch('letsencrypt.cli.client') as client:
|
||||
ret = cli.main(args)
|
||||
return ret, stdout, stderr, client
|
||||
|
||||
def test_no_flags(self):
|
||||
self.assertRaises(SystemExit, self._call, [])
|
||||
|
|
@ -23,6 +24,18 @@ class CLITest(unittest.TestCase):
|
|||
def test_help(self):
|
||||
self.assertRaises(SystemExit, self._call, ['--help'])
|
||||
|
||||
def test_rollback(self):
|
||||
_, _, _, client = self._call(['rollback'])
|
||||
client.rollback.assert_called_once()
|
||||
|
||||
_, _, _, client = self._call(['rollback', '--checkpoints', '123'])
|
||||
client.rollback.assert_called_once_with(
|
||||
mock.ANY, 123, mock.ANY, mock.ANY)
|
||||
|
||||
def test_config_changes(self):
|
||||
_, _, _, client = self._call(['config_changes'])
|
||||
client.view_config_changes.assert_called_once()
|
||||
|
||||
def test_plugins(self):
|
||||
flags = ['--init', '--prepare', '--authenticators', '--installers']
|
||||
for args in itertools.chain(
|
||||
|
|
|
|||
Loading…
Reference in a new issue