From 4fc62cb62b4ed33e64a1be038e22f14b07a212dc Mon Sep 17 00:00:00 2001 From: James Kasten Date: Mon, 8 Dec 2014 15:56:57 -0800 Subject: [PATCH] Fix ApacheConf init and mock correct test object --- letsencrypt/client/apache_configurator.py | 18 ++++++++---------- .../client/tests/apache_configurator_test.py | 12 +++++++++--- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/letsencrypt/client/apache_configurator.py b/letsencrypt/client/apache_configurator.py index 8985bed06..8c243c501 100644 --- a/letsencrypt/client/apache_configurator.py +++ b/letsencrypt/client/apache_configurator.py @@ -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 diff --git a/letsencrypt/client/tests/apache_configurator_test.py b/letsencrypt/client/tests/apache_configurator_test.py index 5ad8ec5fb..3f360e431 100644 --- a/letsencrypt/client/tests/apache_configurator_test.py +++ b/letsencrypt/client/tests/apache_configurator_test.py @@ -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()