test hook dir properties

This commit is contained in:
Brad Warren 2017-09-22 17:19:36 -07:00
parent bd9239a8ca
commit f5288c5bf3

View file

@ -4,6 +4,7 @@ import unittest
import mock
from certbot import constants
from certbot import errors
from certbot.tests import util as test_util
@ -37,14 +38,14 @@ class NamespaceConfigTest(test_util.ConfigTestCase):
self.config.server_path.split(os.path.sep))
@mock.patch('certbot.configuration.constants')
def test_dynamic_dirs(self, constants):
constants.ACCOUNTS_DIR = 'acc'
constants.BACKUP_DIR = 'backups'
constants.CSR_DIR = 'csr'
def test_dynamic_dirs(self, mock_constants):
mock_constants.ACCOUNTS_DIR = 'acc'
mock_constants.BACKUP_DIR = 'backups'
mock_constants.CSR_DIR = 'csr'
constants.IN_PROGRESS_DIR = '../p'
constants.KEY_DIR = 'keys'
constants.TEMP_CHECKPOINT_DIR = 't'
mock_constants.IN_PROGRESS_DIR = '../p'
mock_constants.KEY_DIR = 'keys'
mock_constants.TEMP_CHECKPOINT_DIR = 't'
self.assertEqual(
self.config.accounts_dir, os.path.join(
@ -95,10 +96,10 @@ class NamespaceConfigTest(test_util.ConfigTestCase):
self.assertTrue(os.path.isabs(config.temp_checkpoint_dir))
@mock.patch('certbot.configuration.constants')
def test_renewal_dynamic_dirs(self, constants):
constants.ARCHIVE_DIR = 'a'
constants.LIVE_DIR = 'l'
constants.RENEWAL_CONFIGS_DIR = 'renewal_configs'
def test_renewal_dynamic_dirs(self, mock_constants):
mock_constants.ARCHIVE_DIR = 'a'
mock_constants.LIVE_DIR = 'l'
mock_constants.RENEWAL_CONFIGS_DIR = 'renewal_configs'
self.assertEqual(
self.config.default_archive_dir, os.path.join(self.config.config_dir, 'a'))
@ -134,6 +135,20 @@ class NamespaceConfigTest(test_util.ConfigTestCase):
self.config.namespace.bar = 1337
self.assertEqual(self.config.bar, 1337)
def test_hook_directories(self):
self.assertEqual(self.config.renewal_hooks_dir,
os.path.join(self.config.config_dir,
constants.RENEWAL_HOOKS_DIR))
self.assertEqual(self.config.renewal_pre_hooks_dir,
os.path.join(self.config.renewal_hooks_dir,
constants.RENEWAL_PRE_HOOKS_DIR))
self.assertEqual(self.config.renewal_deploy_hooks_dir,
os.path.join(self.config.renewal_hooks_dir,
constants.RENEWAL_DEPLOY_HOOKS_DIR))
self.assertEqual(self.config.renewal_post_hooks_dir,
os.path.join(self.config.renewal_hooks_dir,
constants.RENEWAL_POST_HOOKS_DIR))
if __name__ == '__main__':
unittest.main() # pragma: no cover