mirror of
https://github.com/certbot/certbot.git
synced 2026-06-03 22:08:07 -04:00
added coverage tests
This commit is contained in:
parent
414cfe9f13
commit
d761df90d4
2 changed files with 18 additions and 4 deletions
|
|
@ -59,7 +59,8 @@ class ApacheParser(object):
|
|||
# Must also attempt to parse sites-available or equivalent
|
||||
# Sites-available is not included naturally in configuration
|
||||
self._parse_file(os.path.join(self.root, "sites-available") + "/*")
|
||||
#TODO check to see if there were unparsed define statements
|
||||
|
||||
#check to see if there were unparsed define statements
|
||||
if self.unparsable:
|
||||
if self.find_dir("Define", exclude=False):
|
||||
raise errors.PluginError("Error parsing runtime variables")
|
||||
|
|
|
|||
|
|
@ -150,9 +150,9 @@ class BasicParserTest(util.ParserTest):
|
|||
|
||||
@mock.patch("letsencrypt_apache.parser.ApacheParser._get_runtime_cfg")
|
||||
def test_update_runtime_vars_bad_output(self, mock_cfg):
|
||||
#mock_cfg.return_value = "Define: TLS=443=24"
|
||||
#self.assertRaises(
|
||||
# errors.PluginError, self.parser.update_runtime_variables, "ctl")
|
||||
mock_cfg.return_value = "Define: TLS=443=24"
|
||||
self.parser.update_runtime_variables("ctl")
|
||||
self.assertTrue( self.parser.unparsable)
|
||||
|
||||
mock_cfg.return_value = "Define: DUMP_RUN_CFG\nDefine: TLS=443=24"
|
||||
self.assertRaises(
|
||||
|
|
@ -185,6 +185,19 @@ class ParserInitTest(util.ApacheTest):
|
|||
shutil.rmtree(self.config_dir)
|
||||
shutil.rmtree(self.work_dir)
|
||||
|
||||
@mock.patch("letsencrypt_apache.parser.ApacheParser._get_runtime_cfg")
|
||||
def test_unparsable(self, mock_cfg):
|
||||
from letsencrypt_apache.parser import ApacheParser
|
||||
def unparsable_true(self, arg):
|
||||
self.unparsable = True
|
||||
with mock.patch.object(ApacheParser, 'update_runtime_variables', autospec=True) as urv:
|
||||
urv.side_effect = unparsable_true
|
||||
mock_cfg.return_value = ('Define: TEST')
|
||||
self.assertRaises(
|
||||
errors.PluginError,
|
||||
ApacheParser, self.aug, os.path.relpath(self.config_path), "ctl")
|
||||
self.assertEquals(1,1)
|
||||
|
||||
def test_root_normalized(self):
|
||||
from letsencrypt_apache.parser import ApacheParser
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue