Skip to content

Commit

Permalink
Remove visible warnings about missing apachectl. (#6307)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmw committed Aug 21, 2018
1 parent b1003b7 commit 0e9dd5e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions certbot/plugins/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ def path_surgery(cmd):
return True
else:
expanded = " expanded" if any(added) else ""
logger.warning("Failed to find executable %s in%s PATH: %s", cmd,
expanded, path)
logger.debug("Failed to find executable %s in%s PATH: %s", cmd,
expanded, path)
return False
9 changes: 3 additions & 6 deletions certbot/plugins/util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,21 @@ def test_get_prefix(self):
class PathSurgeryTest(unittest.TestCase):
"""Tests for certbot.plugins.path_surgery."""

@mock.patch("certbot.plugins.util.logger.warning")
@mock.patch("certbot.plugins.util.logger.debug")
def test_path_surgery(self, mock_debug, mock_warn):
def test_path_surgery(self, mock_debug):
from certbot.plugins.util import path_surgery
all_path = {"PATH": "/usr/local/bin:/bin/:/usr/sbin/:/usr/local/sbin/"}
with mock.patch.dict('os.environ', all_path):
with mock.patch('certbot.util.exe_exists') as mock_exists:
mock_exists.return_value = True
self.assertEqual(path_surgery("eg"), True)
self.assertEqual(mock_debug.call_count, 0)
self.assertEqual(mock_warn.call_count, 0)
self.assertEqual(os.environ["PATH"], all_path["PATH"])
no_path = {"PATH": "/tmp/"}
with mock.patch.dict('os.environ', no_path):
path_surgery("thingy")
self.assertEqual(mock_debug.call_count, 1)
self.assertEqual(mock_warn.call_count, 1)
self.assertTrue("Failed to find" in mock_warn.call_args[0][0])
self.assertEqual(mock_debug.call_count, 2)
self.assertTrue("Failed to find" in mock_debug.call_args[0][0])
self.assertTrue("/usr/local/bin" in os.environ["PATH"])
self.assertTrue("/tmp" in os.environ["PATH"])

Expand Down

0 comments on commit 0e9dd5e

Please sign in to comment.