mirror of
https://github.com/certbot/certbot.git
synced 2026-06-10 17:20:36 -04:00
Add read_file tests
This commit is contained in:
parent
211ca2420f
commit
707df3d2c6
1 changed files with 15 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
"""Tests for letsencrypt.cli."""
|
||||
import argparse
|
||||
import itertools
|
||||
import os
|
||||
import shutil
|
||||
|
|
@ -356,6 +357,20 @@ class CLITest(unittest.TestCase):
|
|||
mock_sys.exit.assert_called_with(''.join(
|
||||
traceback.format_exception_only(KeyboardInterrupt, interrupt)))
|
||||
|
||||
def test_read_file(self):
|
||||
from letsencrypt import cli
|
||||
rel_test_path = os.path.relpath(os.path.join(self.tmp_dir, 'foo'))
|
||||
self.assertRaises(
|
||||
argparse.ArgumentTypeError, cli.read_file, rel_test_path)
|
||||
|
||||
test_contents = 'bar\n'
|
||||
with open(rel_test_path, 'w') as f:
|
||||
f.write(test_contents)
|
||||
|
||||
path, contents = cli.read_file(rel_test_path)
|
||||
self.assertEqual(path, os.path.abspath(path))
|
||||
self.assertEqual(contents, test_contents)
|
||||
|
||||
|
||||
class DetermineAccountTest(unittest.TestCase):
|
||||
"""Tests for letsencrypt.cli._determine_account."""
|
||||
|
|
|
|||
Loading…
Reference in a new issue