diff options
author | Brad Warren <bmw@users.noreply.github.com> | 2016-10-13 23:54:22 +0300 |
---|---|---|
committer | Brad Warren <bmw@eff.org> | 2016-10-14 04:06:03 +0300 |
commit | 4fcc3c8d0ce3ac1aea1aafe3c68beffa522540b3 (patch) | |
tree | 94a1a8db8fbd82488c9e51d1d8bb82b1db71de17 | |
parent | 342e0d1184419eafd4799c4916c06dfa57e059b3 (diff) |
Fix Apache constants tests (#3630)
* Allow running constants_test.py individually
* Mock until tests pass
Mock out both functions used to determine the OS in
certbot_apache.tests.constants_test.
(cherry picked from commit 6d0ba6de8e3151143e85c944fdbbb698f085fe37)
-rw-r--r-- | certbot-apache/certbot_apache/tests/constants_test.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/certbot-apache/certbot_apache/tests/constants_test.py b/certbot-apache/certbot_apache/tests/constants_test.py index 1c842aee9..5ab324101 100644 --- a/certbot-apache/certbot_apache/tests/constants_test.py +++ b/certbot-apache/certbot_apache/tests/constants_test.py @@ -20,25 +20,25 @@ class ConstantsTest(unittest.TestCase): self.assertEqual(constants.os_constant("vhost_root"), "/etc/httpd/conf.d") + @mock.patch("certbot.util.get_systemd_os_like") @mock.patch("certbot.util.get_os_info") - def test_get_default_value(self, os_info): + def test_get_default_values(self, os_info, os_like): os_info.return_value = ('Nonexistent Linux', '', '') + os_like.return_value = {} + self.assertFalse(constants.os_constant("handle_mods")) + self.assertEqual(constants.os_constant("server_root"), "/etc/apache2") self.assertEqual(constants.os_constant("vhost_root"), "/etc/apache2/sites-available") + @mock.patch("certbot.util.get_systemd_os_like") @mock.patch("certbot.util.get_os_info") - def test_get_default_constants(self, os_info): + def test_get_darwin_like_values(self, os_info, os_like): os_info.return_value = ('Nonexistent Linux', '', '') - with mock.patch("certbot.util.get_systemd_os_like") as os_like: - # Get defaults - os_like.return_value = False - c_hm = constants.os_constant("handle_mods") - c_sr = constants.os_constant("server_root") - self.assertFalse(c_hm) - self.assertEqual(c_sr, "/etc/apache2") - # Use darwin as like test target - os_like.return_value = ["something", "nonexistent", "darwin"] - d_vr = constants.os_constant("vhost_root") - d_em = constants.os_constant("enmod") - self.assertFalse(d_em) - self.assertEqual(d_vr, "/etc/apache2/other") + os_like.return_value = ["something", "nonexistent", "darwin"] + self.assertFalse(constants.os_constant("enmod")) + self.assertEqual(constants.os_constant("vhost_root"), + "/etc/apache2/other") + + +if __name__ == "__main__": + unittest.main() # pragma: no cover |