mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 02:44:21 +02:00
Refactor and lint fixes
This commit is contained in:
@@ -28,6 +28,18 @@ class AugeasConfigurator(common.Plugin):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(AugeasConfigurator, self).__init__(*args, **kwargs)
|
super(AugeasConfigurator, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
# Placeholder for augeas
|
||||||
|
self.aug = None
|
||||||
|
|
||||||
|
self.save_notes = ""
|
||||||
|
|
||||||
|
# See if any temporary changes need to be recovered
|
||||||
|
# This needs to occur before VirtualHost objects are setup...
|
||||||
|
# because this will change the underlying configuration and potential
|
||||||
|
# vhosts
|
||||||
|
self.reverter = reverter.Reverter(self.config)
|
||||||
|
self.recovery_routine()
|
||||||
|
|
||||||
def init_augeas(self):
|
def init_augeas(self):
|
||||||
""" Initialize the actual Augeas instance """
|
""" Initialize the actual Augeas instance """
|
||||||
import augeas
|
import augeas
|
||||||
@@ -37,14 +49,6 @@ class AugeasConfigurator(common.Plugin):
|
|||||||
# Do not save backup (we do it ourselves), do not load
|
# Do not save backup (we do it ourselves), do not load
|
||||||
# anything by default
|
# anything by default
|
||||||
flags=(augeas.Augeas.NONE | augeas.Augeas.NO_MODL_AUTOLOAD))
|
flags=(augeas.Augeas.NONE | augeas.Augeas.NO_MODL_AUTOLOAD))
|
||||||
self.save_notes = ""
|
|
||||||
|
|
||||||
# See if any temporary changes need to be recovered
|
|
||||||
# This needs to occur before VirtualHost objects are setup...
|
|
||||||
# because this will change the underlying configuration and potential
|
|
||||||
# vhosts
|
|
||||||
self.reverter = reverter.Reverter(self.config)
|
|
||||||
self.recovery_routine()
|
|
||||||
|
|
||||||
def check_parsing_errors(self, lens):
|
def check_parsing_errors(self, lens):
|
||||||
"""Verify Augeas can parse all of the lens files.
|
"""Verify Augeas can parse all of the lens files.
|
||||||
|
|||||||
@@ -57,7 +57,9 @@ class MultipleVhostsTest(util.ApacheTest):
|
|||||||
|
|
||||||
@mock.patch("certbot_apache.augeas_configurator.AugeasConfigurator.init_augeas")
|
@mock.patch("certbot_apache.augeas_configurator.AugeasConfigurator.init_augeas")
|
||||||
def test_prepare_no_augeas(self, mock_init_augeas):
|
def test_prepare_no_augeas(self, mock_init_augeas):
|
||||||
def side_effect_error(*args, **kwargs):
|
""" Test augeas initialization ImportError """
|
||||||
|
def side_effect_error():
|
||||||
|
""" Side effect error for the test """
|
||||||
raise ImportError
|
raise ImportError
|
||||||
mock_init_augeas.side_effect = side_effect_error
|
mock_init_augeas.side_effect = side_effect_error
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
|
|||||||
Reference in New Issue
Block a user