diff options
author | Jonathan Sandoval <jsandoval@utp.edu.co> | 2016-04-08 13:07:06 -0500 |
---|---|---|
committer | Jonathan Sandoval <jsandoval@utp.edu.co> | 2016-04-08 13:07:06 -0500 |
commit | 9d37bcd06fae5e8cbebf68aaf8670551fe6e5db1 (patch) | |
tree | 8a92f98311604f741ebbbf7d4007b53d260f5688 /mediagoblin/tests | |
parent | 41302ad2b622b340caeb13339338ab3a5d0f7e6b (diff) | |
download | mediagoblin-9d37bcd06fae5e8cbebf68aaf8670551fe6e5db1.tar.lz mediagoblin-9d37bcd06fae5e8cbebf68aaf8670551fe6e5db1.tar.xz mediagoblin-9d37bcd06fae5e8cbebf68aaf8670551fe6e5db1.zip |
Mail tests with no mail server configured.
Diffstat (limited to 'mediagoblin/tests')
-rw-r--r-- | mediagoblin/tests/test_util.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/mediagoblin/tests/test_util.py b/mediagoblin/tests/test_util.py index 8193233f..014c5eb8 100644 --- a/mediagoblin/tests/test_util.py +++ b/mediagoblin/tests/test_util.py @@ -181,3 +181,28 @@ def test_html_cleaner(): '<p><a href="javascript:nasty_surprise">innocent link!</a></p>') assert result == ( '<p><a href="">innocent link!</a></p>') +class TestMail(object): + """ Test mediagoblin's mail tool """ + def test_no_mail_server(self): + """ Tests that no smtp server is available """ + with pytest.raises(mail.NoSMTPServerError), mock.patch("smtplib.SMTP") as smtp_mock: + smtp_mock.side_effect = socket.error + mg_globals.app_config = { + "email_debug_mode": False, + "email_smtp_use_ssl": False, + "email_smtp_host": "127.0.0.1", + "email_smtp_port": 0} + common.TESTS_ENABLED = False + mail.send_email("", "", "", "") + + def test_no_smtp_host(self): + """ Empty email_smtp_host """ + with pytest.raises(mail.NoSMTPServerError), mock.patch("smtplib.SMTP") as smtp_mock: + smtp_mock.return_value.connect.side_effect = socket.error + mg_globals.app_config = { + "email_debug_mode": False, + "email_smtp_use_ssl": False, + "email_smtp_host": "", + "email_smtp_port": 0} + common.TESTS_ENABLED = False + mail.send_email("", "", "", "") |