Unverified Commit 3e9e97e6 by Eric Fischer Committed by GitHub

Merge pull request #16635 from edx/efischer/EDUCATOR-1773

No unicode in "from" value on Bulk Emails
parents 0d931107 19c580e5
...@@ -416,6 +416,13 @@ def _get_source_address(course_id, course_title, course_language, truncate=True) ...@@ -416,6 +416,13 @@ def _get_source_address(course_id, course_title, course_language, truncate=True)
if len(escaped_encoded_from_addr) >= 320 and truncate: if len(escaped_encoded_from_addr) >= 320 and truncate:
from_addr = format_address(course_name) from_addr = format_address(course_name)
# EDUCATOR-1773: Courses with unicode in the title are not handled by django-ses logging
# remove this block once https://github.com/django-ses/django-ses/issues/137 is resolved and released
try:
dummy_var = "not a unicode string {}".format(from_addr)
except UnicodeEncodeError:
from_addr = format_address(course_name)
return from_addr return from_addr
......
...@@ -4,7 +4,7 @@ Unit tests for sending course email ...@@ -4,7 +4,7 @@ Unit tests for sending course email
""" """
import json import json
import os import os
from unittest import skipIf from unittest import skip, skipIf
import ddt import ddt
from django.conf import settings from django.conf import settings
...@@ -267,6 +267,8 @@ class TestEmailSendFromDashboardMockedHtmlToText(EmailSendFromDashboardTestCase) ...@@ -267,6 +267,8 @@ class TestEmailSendFromDashboardMockedHtmlToText(EmailSendFromDashboardTestCase)
self.assertEqual(len(mail.outbox[0].to), 1) self.assertEqual(len(mail.outbox[0].to), 1)
self.assertEquals(mail.outbox[0].to[0], self.instructor.email) self.assertEquals(mail.outbox[0].to[0], self.instructor.email)
self.assertEquals(mail.outbox[0].subject, 'test subject for myself') self.assertEquals(mail.outbox[0].subject, 'test subject for myself')
"""
TODO - uncomment this assertion and delete the following alternate once django-ses is fixed. EDUCATOR-1773
self.assertEquals( self.assertEquals(
mail.outbox[0].from_email, mail.outbox[0].from_email,
u'"{course_display_name}" Course Staff <{course_name}-no-reply@example.com>'.format( u'"{course_display_name}" Course Staff <{course_name}-no-reply@example.com>'.format(
...@@ -274,6 +276,14 @@ class TestEmailSendFromDashboardMockedHtmlToText(EmailSendFromDashboardTestCase) ...@@ -274,6 +276,14 @@ class TestEmailSendFromDashboardMockedHtmlToText(EmailSendFromDashboardTestCase)
course_name=self.course.id.course course_name=self.course.id.course
) )
) )
""" # pylint: disable=pointless-string-statement
self.assertEquals(
mail.outbox[0].from_email,
u'"{course_display_name}" Course Staff <{course_name}-no-reply@example.com>'.format(
course_display_name=self.course.number,
course_name=self.course.id.course
)
)
def test_send_to_staff(self): def test_send_to_staff(self):
""" """
...@@ -499,6 +509,7 @@ class TestEmailSendFromDashboardMockedHtmlToText(EmailSendFromDashboardTestCase) ...@@ -499,6 +509,7 @@ class TestEmailSendFromDashboardMockedHtmlToText(EmailSendFromDashboardTestCase)
[self.instructor.email] + [s.email for s in self.staff] + [s.email for s in self.students] [self.instructor.email] + [s.email for s in self.staff] + [s.email for s in self.students]
) )
@skip("Unicode course names are broken, see EDUCATOR-1773 for details. Un-skip after django-ses is fixed.")
@override_settings(BULK_EMAIL_DEFAULT_FROM_EMAIL="no-reply@courseupdates.edx.org") @override_settings(BULK_EMAIL_DEFAULT_FROM_EMAIL="no-reply@courseupdates.edx.org")
def test_long_course_display_name(self): def test_long_course_display_name(self):
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment