diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2014-09-16 14:01:43 -0500 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2014-09-16 14:01:43 -0500 |
commit | f6bad0eb26fa7e092570afe1fb7f38b3d1a1941d (patch) | |
tree | 0ca05e7a95cfb30d8b286f3ec72e8c95e212511b /mediagoblin/tests/test_util.py | |
parent | 5b64c92e0816e733c2f88b88ddc0aec070cdc0d3 (diff) | |
parent | 1b4e199668ada5c2ec47df7432ab69e315dc0601 (diff) | |
download | mediagoblin-f6bad0eb26fa7e092570afe1fb7f38b3d1a1941d.tar.lz mediagoblin-f6bad0eb26fa7e092570afe1fb7f38b3d1a1941d.tar.xz mediagoblin-f6bad0eb26fa7e092570afe1fb7f38b3d1a1941d.zip |
Merge branch 'master' into merge-python3-port
Has some issues, will iteratively fix!
Conflicts:
mediagoblin/gmg_commands/__init__.py
mediagoblin/gmg_commands/deletemedia.py
mediagoblin/gmg_commands/users.py
mediagoblin/oauth/views.py
mediagoblin/plugins/api/views.py
mediagoblin/tests/test_api.py
mediagoblin/tests/test_edit.py
mediagoblin/tests/test_oauth1.py
mediagoblin/tests/test_util.py
mediagoblin/tools/mail.py
mediagoblin/webfinger/views.py
setup.py
Diffstat (limited to 'mediagoblin/tests/test_util.py')
-rw-r--r-- | mediagoblin/tests/test_util.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/mediagoblin/tests/test_util.py b/mediagoblin/tests/test_util.py index e239d628..e1c3c7e5 100644 --- a/mediagoblin/tests/test_util.py +++ b/mediagoblin/tests/test_util.py @@ -14,10 +14,15 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +import mock import email +import pytest +import smtplib +import pkg_resources import six +from mediagoblin.tests.tools import get_app from mediagoblin.tools import common, url, translate, mail, text, testing testing._activate_testing() @@ -71,6 +76,28 @@ I hope you like unit tests JUST AS MUCH AS I DO!""" I hope you like unit tests JUST AS MUCH AS I DO!""" +@pytest.fixture() +def starttls_enabled_app(request): + return get_app( + request, + mgoblin_config=pkg_resources.resource_filename( + "mediagoblin.tests", + "starttls_config.ini" + ) + ) + +def test_email_force_starttls(starttls_enabled_app): + common.TESTS_ENABLED = False + SMTP = lambda *args, **kwargs: mail.FakeMhost() + with mock.patch('smtplib.SMTP', SMTP): + with pytest.raises(smtplib.SMTPException): + mail.send_email( + from_addr="notices@my.test.instance.com", + to_addrs="someone@someplace.com", + subject="Testing is so much fun!", + message_body="Ohai ^_^" + ) + def test_slugify(): assert url.slugify(u'a walk in the park') == u'a-walk-in-the-park' assert url.slugify(u'A Walk in the Park') == u'a-walk-in-the-park' |