Fix ApacheConf init and mock correct test object

This commit is contained in:
James Kasten 2014-12-08 15:56:57 -08:00
parent 19501d297d
commit 4fc62cb62b
2 changed files with 17 additions and 13 deletions

View file

@ -126,16 +126,12 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
"""
def __init__(self, server_root=CONFIG.SERVER_ROOT, dir=None, version=None):
"""Initialize an Apache Configurator."""
# The top 3 are the only ones that need to be
# defined for Augeas Configurator
if dir:
self.dir = dir
else:
self.dir = {"backup": CONFIG.BACKUP_DIR,
"temp": CONFIG.TEMP_CHECKPOINT_DIR,
"progress": CONFIG.IN_PROGRESS_DIR,
"config": CONFIG.CONFIG_DIR,
"work": CONFIG.WORK_DIR}
if not dir:
dir = {"backup": CONFIG.BACKUP_DIR,
"temp": CONFIG.TEMP_CHECKPOINT_DIR,
"progress": CONFIG.IN_PROGRESS_DIR,
"config": CONFIG.CONFIG_DIR,
"work": CONFIG.WORK_DIR}
super(ApacheConfigurator, self).__init__(dir)
@ -1558,6 +1554,8 @@ def check_ssl_loaded():
logger.error("This may be caused by an Apache Configuration Error")
return False
print "%%%%%%%% PROC:", proc
if "ssl_module" in proc:
return True
return False

View file

@ -48,12 +48,12 @@ class TwoVhost80(unittest.TestCase):
"""Standard two http vhosts that are well configured."""
@mock.patch("letsencrypt.client.apache_configurator."
"subprocess.Popen.communicate")
def setUp(self, mock_subprocess):
"subprocess.Popen")
def setUp(self, mock_Popen):
"""Run before each and every tests."""
# This just states that the ssl module is already loaded
mock_subprocess.return_value = ("ssl_module", "")
mock_Popen.return_value = my_Popen()
# Final slash is currently important
self.config_path = os.path.join(TEMP_DIR, "two_vhost_80/apache2/")
@ -258,5 +258,11 @@ def debug_file(filepath):
with open(filepath, 'r')as file_d:
print file_d.read()
# I am sure there is a cleaner way to do this... but it works
class my_Popen(object):
def communicate(self):
return "ssl_module", ""
if __name__ == '__main__':
unittest.main()