aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tests/test_util.py
diff options
context:
space:
mode:
authorJessica Tallon <jessica@megworld.co.uk>2014-08-12 16:56:08 +0100
committerJessica Tallon <jessica@megworld.co.uk>2014-08-12 19:23:19 +0100
commit7ffd4cf4b5e3a1358c189ad49c01a3b3f4198ba4 (patch)
treee54ca8dcc442d13753c2afdb64b7a6ed138aaab7 /mediagoblin/tests/test_util.py
parent3b104bbcefca052eb3814f015521b47d2fcbc0da (diff)
downloadmediagoblin-7ffd4cf4b5e3a1358c189ad49c01a3b3f4198ba4.tar.lz
mediagoblin-7ffd4cf4b5e3a1358c189ad49c01a3b3f4198ba4.tar.xz
mediagoblin-7ffd4cf4b5e3a1358c189ad49c01a3b3f4198ba4.zip
Fix #861 - Add unit test and documentation for email_smtp_force_starttls
Diffstat (limited to 'mediagoblin/tests/test_util.py')
-rw-r--r--mediagoblin/tests/test_util.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/mediagoblin/tests/test_util.py b/mediagoblin/tests/test_util.py
index 9d9b1c16..36563e75 100644
--- a/mediagoblin/tests/test_util.py
+++ b/mediagoblin/tests/test_util.py
@@ -14,8 +14,13 @@
# 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
+from mediagoblin.tests.tools import get_app
from mediagoblin.tools import common, url, translate, mail, text, testing
testing._activate_testing()
@@ -69,6 +74,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'