/usr/lib/python3/dist-packages/certbot/tests
NameSizeModeActions
compat/-0755rm
display/-0755rm
testdata/-0755rm
__pycache__/-0755rm
account_test.py141180644editdlrm
acme_util.py29180644editdlrm
auth_handler_test.py223090644editdlrm
cert_manager_test.py288370644editdlrm
client_test.py324990644editdlrm
cli_test.py217680644editdlrm
configuration_test.py69860644editdlrm
crypto_util_test.py137490644editdlrm
eff_test.py60810644editdlrm
errors_test.py18470644editdlrm
error_handler_test.py52610644editdlrm
hook_test.py178560644editdlrm
lock_test.py49900644editdlrm
log_test.py152620644editdlrm
main_test.py847430644editdlrm
notify_test.py21170644editdlrm
ocsp_test.py166880644editdlrm
renewal_test.py51460644editdlrm
renewupdater_test.py54510644editdlrm
reporter_test.py27990644editdlrm
reverter_test.py185310644editdlrm
storage_test.py426280644editdlrm
util.py141010644editdlrm
util_test.py217060644editdlrm
__init__.py200644editdlrm
Edit: /usr/lib/python3/dist-packages/certbot/tests/notify_test.py (2117B)
"""Tests for certbot.notify.""" import socket import unittest import mock class NotifyTests(unittest.TestCase): """Tests for the notifier.""" @mock.patch("certbot.notify.smtplib.LMTP") def test_smtp_success(self, mock_lmtp): from certbot.notify import notify lmtp_obj = mock.MagicMock() mock_lmtp.return_value = lmtp_obj self.assertTrue(notify("Goose", "auntrhody@example.com", "The old grey goose is dead.")) self.assertEqual(lmtp_obj.connect.call_count, 1) self.assertEqual(lmtp_obj.sendmail.call_count, 1) @mock.patch("certbot.notify.smtplib.LMTP") @mock.patch("certbot.notify.subprocess.Popen") def test_smtp_failure(self, mock_popen, mock_lmtp): from certbot.notify import notify lmtp_obj = mock.MagicMock() mock_lmtp.return_value = lmtp_obj lmtp_obj.sendmail.side_effect = socket.error(17) proc = mock.MagicMock() mock_popen.return_value = proc self.assertTrue(notify("Goose", "auntrhody@example.com", "The old grey goose is dead.")) self.assertEqual(lmtp_obj.sendmail.call_count, 1) self.assertEqual(proc.communicate.call_count, 1) @mock.patch("certbot.notify.smtplib.LMTP") @mock.patch("certbot.notify.subprocess.Popen") def test_everything_fails(self, mock_popen, mock_lmtp): from certbot.notify import notify lmtp_obj = mock.MagicMock() mock_lmtp.return_value = lmtp_obj lmtp_obj.sendmail.side_effect = socket.error(17) proc = mock.MagicMock() mock_popen.return_value = proc proc.communicate.side_effect = OSError("What we have here is a " "failure to communicate.") self.assertFalse(notify("Goose", "auntrhody@example.com", "The old grey goose is dead.")) self.assertEqual(lmtp_obj.sendmail.call_count, 1) self.assertEqual(proc.communicate.call_count, 1) if __name__ == "__main__": unittest.main() # pragma: no cover