コード例 #1
0
 def test_send_email_completed_subtask(self):
     # test at a lower level, to ensure that the course gets checked down below too.
     entry = InstructorTask.create(self.course.id, "task_type", "task_key", "task_input", self.instructor)
     entry_id = entry.id  # pylint: disable=E1101
     subtask_id = "subtask-id-value"
     initialize_subtask_info(entry, "emailed", 100, [subtask_id])
     subtask_status = create_subtask_status(subtask_id, state=SUCCESS)
     update_subtask_status(entry_id, subtask_id, subtask_status)
     bogus_email_id = 1001
     to_list = ['*****@*****.**']
     global_email_context = {'course_title': 'dummy course'}
     new_subtask_status = create_subtask_status(subtask_id)
     with self.assertRaisesRegexp(DuplicateTaskException, 'already completed'):
         send_course_email(entry_id, bogus_email_id, to_list, global_email_context, new_subtask_status)
コード例 #2
0
 def test_send_email_undefined_subtask(self):
     # test at a lower level, to ensure that the course gets checked down below too.
     entry = InstructorTask.create(self.course.id, "task_type", "task_key", "task_input", self.instructor)
     entry_id = entry.id  # pylint: disable=E1101
     to_list = ['*****@*****.**']
     global_email_context = {'course_title': 'dummy course'}
     subtask_id = "subtask-id-value"
     subtask_status = create_subtask_status(subtask_id)
     email_id = 1001
     with self.assertRaisesRegexp(ValueError, 'unable to find email subtasks of instructor task'):
         send_course_email(entry_id, email_id, to_list, global_email_context, subtask_status)
コード例 #3
0
 def test_send_email_missing_subtask(self):
     # test at a lower level, to ensure that the course gets checked down below too.
     entry = InstructorTask.create(self.course.id, "task_type", "task_key", "task_input", self.instructor)
     entry_id = entry.id  # pylint: disable=E1101
     to_list = ['*****@*****.**']
     global_email_context = {'course_title': 'dummy course'}
     subtask_id = "subtask-id-value"
     initialize_subtask_info(entry, "emailed", 100, [subtask_id])
     different_subtask_id = "bogus-subtask-id-value"
     subtask_status = create_subtask_status(different_subtask_id)
     bogus_email_id = 1001
     with self.assertRaisesRegexp(ValueError, 'unable to find status for email subtask of instructor task'):
         send_course_email(entry_id, bogus_email_id, to_list, global_email_context, subtask_status)
コード例 #4
0
 def test_send_email_undefined_email(self):
     # test at a lower level, to ensure that the course gets checked down below too.
     entry = InstructorTask.create(self.course.id, "task_type", "task_key", "task_input", self.instructor)
     entry_id = entry.id  # pylint: disable=E1101
     to_list = ['*****@*****.**']
     global_email_context = {'course_title': 'dummy course'}
     subtask_id = "subtask-id-value"
     subtask_status = create_subtask_status(subtask_id)
     bogus_email_id = 1001
     with self.assertRaises(CourseEmail.DoesNotExist):
         # we skip the call that updates subtask status, since we've not set up the InstructorTask
         # for the subtask, and it's not important to the test.
         with patch('bulk_email.tasks.update_subtask_status'):
             send_course_email(entry_id, bogus_email_id, to_list, global_email_context, subtask_status)
コード例 #5
0
ファイル: tasks.py プロジェクト: chenkaigithub/edx-platform
 def _create_send_email_subtask(to_list, subtask_id):
     """Creates a subtask to send email to a given recipient list."""
     subtask_status = create_subtask_status(subtask_id)
     new_subtask = send_course_email.subtask(
         (
             entry_id,
             email_id,
             to_list,
             global_email_context,
             subtask_status,
         ),
         task_id=subtask_id,
         routing_key=settings.BULK_EMAIL_ROUTING_KEY,
     )
     return new_subtask