Refactor and lint fixes

This commit is contained in:
Joona Hoikkala 2016-06-06 12:44:49 +03:00
parent 7239361342
commit e263132283
No known key found for this signature in database
GPG key ID: C14AAE0F5ADCB854
2 changed files with 15 additions and 9 deletions

View file

@ -28,6 +28,18 @@ class AugeasConfigurator(common.Plugin):
def __init__(self, *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):
""" Initialize the actual Augeas instance """
import augeas
@ -37,14 +49,6 @@ class AugeasConfigurator(common.Plugin):
# Do not save backup (we do it ourselves), do not load
# anything by default
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):
"""Verify Augeas can parse all of the lens files.

View file

@ -57,7 +57,9 @@ class MultipleVhostsTest(util.ApacheTest):
@mock.patch("certbot_apache.augeas_configurator.AugeasConfigurator.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
mock_init_augeas.side_effect = side_effect_error
self.assertRaises(