Ejemplo n.º 1
0
 def test_wrong_course_id_in_email(self):
     """
     Tests exception when the course_id in CourseEmail is not the same as one explicitly passed in.
     """
     email = CourseEmail.create(CourseLocator("bogus", "course", "id"),
                                self.instructor, [SEND_TO_MYSELF],
                                "re: subject", "dummy body goes here")
     entry = InstructorTask.create(self.course.id, "task_type", "task_key",
                                   "task_input", self.instructor)
     task_input = {"email_id": email.id}
     with self.assertRaisesRegex(ValueError, 'does not match email value'):
         perform_delegate_email_batches(entry.id, self.course.id,
                                        task_input, "action_name")
Ejemplo n.º 2
0
 def test_nonexistent_course(self):
     """
     Tests exception when the course in the email doesn't exist
     """
     course_id = CourseLocator("I", "DONT", "EXIST")
     email = CourseEmail(course_id=course_id)
     email.save()
     entry = InstructorTask.create(course_id, "task_type", "task_key",
                                   "task_input", self.instructor)
     task_input = {"email_id": email.id}
     with pytest.raises(CourseRunNotFound):
         perform_delegate_email_batches(entry.id, course_id, task_input,
                                        "action_name")
Ejemplo n.º 3
0
 def test_nonexistent_course(self):
     """
     Tests exception when the course in the email doesn't exist
     """
     course_id = CourseLocator("I", "DONT", "EXIST")
     email = CourseEmail(course_id=course_id)
     email.save()
     entry = InstructorTask.create(course_id, "task_type", "task_key",
                                   "task_input", self.instructor)
     task_input = {"email_id": email.id}
     # (?i) is a regex for ignore case
     with self.assertRaisesRegex(ValueError, r"(?i)course not found"):
         perform_delegate_email_batches(entry.id, course_id, task_input,
                                        "action_name")
Ejemplo n.º 4
0
 def test_nonexistent_email(self, mock_log, result):
     """
     Tests retries when the email doesn't exist
     """
     # create an InstructorTask object to pass through
     course_id = self.course.id
     entry = InstructorTask.create(course_id, "task_type", "task_key",
                                   "task_input", self.instructor)
     task_input = {"email_id": -1}
     with pytest.raises(CourseEmail.DoesNotExist):
         perform_delegate_email_batches(entry.id, course_id, task_input,
                                        "action_name")
     ((log_str, __, email_id), __) = mock_log.warning.call_args
     assert mock_log.warning.called
     assert 'Failed to get CourseEmail with id' in log_str
     assert email_id == (-1)
     assert not result.called