diff --git a/lms/djangoapps/bulk_email/tasks.py b/lms/djangoapps/bulk_email/tasks.py index 9b12740413..d88b08a9d0 100644 --- a/lms/djangoapps/bulk_email/tasks.py +++ b/lms/djangoapps/bulk_email/tasks.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ This module contains celery task functions for handling the sending of bulk email to a course. @@ -152,7 +153,7 @@ def _get_course_email_context(course): settings.SITE_NAME, reverse('course_root', kwargs={'course_id': course_id}) ) - image_url = 'https://{}{}'.format(settings.SITE_NAME, course_image_url(course)) + image_url = u'https://{}{}'.format(settings.SITE_NAME, course_image_url(course)) email_context = { 'course_title': course_title, 'course_url': course_url, diff --git a/lms/djangoapps/bulk_email/tests/test_tasks.py b/lms/djangoapps/bulk_email/tests/test_tasks.py index c8b0172290..33f1c5009d 100644 --- a/lms/djangoapps/bulk_email/tests/test_tasks.py +++ b/lms/djangoapps/bulk_email/tests/test_tasks.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ Unit tests for LMS instructor-initiated background tasks. @@ -29,6 +30,8 @@ from celery.states import SUCCESS, FAILURE from django.conf import settings from django.core.management import call_command +from xmodule.modulestore.tests.factories import CourseFactory + from bulk_email.models import CourseEmail, Optout, SEND_TO_ALL from instructor_task.tasks import send_bulk_course_email @@ -404,3 +407,15 @@ class TestBulkEmailInstructorTask(InstructorTaskCourseTestCase): def test_failure_on_ses_domain_not_confirmed(self): self._test_immediate_failure(SESDomainNotConfirmedError(403, "You're out of bounds!")) + + def test_bulk_emails_with_unicode_course_image_name(self): + # Test bulk email with unicode characters in course image name + course_image = u'在淡水測試.jpg' + self.course = CourseFactory.create(course_image=course_image) + + num_emails = 1 + self._create_students(num_emails) + + with patch('bulk_email.tasks.get_connection', autospec=True) as get_conn: + get_conn.return_value.send_messages.side_effect = cycle([None]) + self._test_run_with_task(send_bulk_course_email, 'emailed', num_emails, num_emails)