mirror of
https://github.com/certbot/certbot.git
synced 2026-06-08 16:22:18 -04:00
Add SetupLogFileHandlerTest
This commit is contained in:
parent
f3c6bac310
commit
4f35f3fdf7
1 changed files with 24 additions and 0 deletions
|
|
@ -1,10 +1,13 @@
|
|||
"""Tests for certbot.main."""
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
import mock
|
||||
|
||||
from certbot import cli
|
||||
from certbot import configuration
|
||||
from certbot import errors
|
||||
from certbot.plugins import disco as plugins_disco
|
||||
|
||||
|
||||
|
|
@ -42,5 +45,26 @@ class ObtainCertTest(unittest.TestCase):
|
|||
self.assertFalse(pause)
|
||||
|
||||
|
||||
class SetupLogFileHandlerTest(unittest.TestCase):
|
||||
"""Tests for certbot.main.setup_log_file_handler."""
|
||||
|
||||
def setUp(self):
|
||||
self.config = mock.Mock(spec_set=['logs_dir'],
|
||||
logs_dir=tempfile.mkdtemp())
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.config.logs_dir)
|
||||
|
||||
def _call(self, *args, **kwargs):
|
||||
from certbot.main import setup_log_file_handler
|
||||
return setup_log_file_handler(*args, **kwargs)
|
||||
|
||||
@mock.patch('certbot.main.logging.handlers.RotatingFileHandler')
|
||||
def test_ioerror(self, mock_handler):
|
||||
mock_handler.side_effect = IOError
|
||||
self.assertRaises(errors.Error, self._call,
|
||||
self.config, "test.log", "%s")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main() # pragma: no cover
|
||||
|
|
|
|||
Loading…
Reference in a new issue