mirror of
https://github.com/certbot/certbot.git
synced 2026-08-05 13:02:04 +02:00
Fix _run_hook test
This commit is contained in:
@@ -81,18 +81,19 @@ class HookTest(unittest.TestCase):
|
|||||||
self._test_a_hook(config, rhook, 0)
|
self._test_a_hook(config, rhook, 0)
|
||||||
self.assertEqual(mock_print.call_count, 2)
|
self.assertEqual(mock_print.call_count, 2)
|
||||||
|
|
||||||
@mock.patch('letsencrypt.hooks.logger.error')
|
|
||||||
@mock.patch('letsencrypt.hooks.Popen')
|
@mock.patch('letsencrypt.hooks.Popen')
|
||||||
def test_run_hook(self, mock_popen, mock_error):
|
def test_run_hook(self, mock_popen):
|
||||||
mock_cmd = mock.MagicMock()
|
with mock.patch('letsencrypt.hooks.logger.error') as mock_error:
|
||||||
mock_cmd.returncode = 1
|
mock_cmd = mock.MagicMock()
|
||||||
mock_cmd.communicate.return_value = ("", "")
|
mock_cmd.returncode = 1
|
||||||
mock_popen.return_value = mock_cmd
|
mock_cmd.communicate.return_value = ("", "")
|
||||||
hooks._run_hook("ls")
|
mock_popen.return_value = mock_cmd
|
||||||
self.assertEqual(mock_error.call_count, 1)
|
hooks._run_hook("ls")
|
||||||
mock_cmd.communicate.return_value = ("", "thing")
|
self.assertEqual(mock_error.call_count, 1)
|
||||||
hooks._run_hook("ls")
|
with mock.patch('letsencrypt.hooks.logger.error') as mock_error:
|
||||||
self.assertEqual(mock_error.call_count, 2)
|
mock_cmd.communicate.return_value = ("", "thing")
|
||||||
|
hooks._run_hook("ls")
|
||||||
|
self.assertEqual(mock_error.call_count, 2)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in New Issue
Block a user