Commit f199c305 by Syed Hassan Raza

bulk_email fix course_image_unicode name

parent 7b535846
# -*- coding: utf-8 -*-
""" """
This module contains celery task functions for handling the sending of bulk email This module contains celery task functions for handling the sending of bulk email
to a course. to a course.
...@@ -152,7 +153,7 @@ def _get_course_email_context(course): ...@@ -152,7 +153,7 @@ def _get_course_email_context(course):
settings.SITE_NAME, settings.SITE_NAME,
reverse('course_root', kwargs={'course_id': course_id}) 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 = { email_context = {
'course_title': course_title, 'course_title': course_title,
'course_url': course_url, 'course_url': course_url,
......
# -*- coding: utf-8 -*-
""" """
Unit tests for LMS instructor-initiated background tasks. Unit tests for LMS instructor-initiated background tasks.
...@@ -28,6 +29,8 @@ from celery.states import SUCCESS, FAILURE ...@@ -28,6 +29,8 @@ from celery.states import SUCCESS, FAILURE
from django.conf import settings from django.conf import settings
from django.core.management import call_command 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 bulk_email.models import CourseEmail, Optout, SEND_TO_ALL
from instructor_task.tasks import send_bulk_course_email from instructor_task.tasks import send_bulk_course_email
...@@ -408,3 +411,15 @@ class TestBulkEmailInstructorTask(InstructorTaskCourseTestCase): ...@@ -408,3 +411,15 @@ class TestBulkEmailInstructorTask(InstructorTaskCourseTestCase):
def test_failure_on_ses_domain_not_confirmed(self): def test_failure_on_ses_domain_not_confirmed(self):
self._test_immediate_failure(SESDomainNotConfirmedError(403, "You're out of bounds!")) 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)
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