Ejemplo n.º 1
0
 def test_nonexist_course(self, mock_log):
     """
     Tests exception when the course in the email doesn't exist
     """
     email = CourseEmail(course_id="I/DONT/EXIST")
     email.save()
     delegate_email_batches.delay(email.id, self.instructor.id)
     ((log_str, _), _) = mock_log.exception.call_args
     self.assertTrue(mock_log.exception.called)
     self.assertIn('get_course_by_id failed:', log_str)
Ejemplo n.º 2
0
 def test_nonexistent_to_option(self):
     """
     Tests exception when the to_option in the email doesn't exist
     """
     email = CourseEmail(course_id=self.course.id, to_option="IDONTEXIST")
     email.save()
     entry = InstructorTask.create(self.course.id, "task_type", "task_key", "task_input", self.instructor)
     task_input = {"email_id": email.id}  # pylint: disable=no-member
     with self.assertRaisesRegexp(Exception, 'Unexpected bulk email TO_OPTION found: IDONTEXIST'):
         perform_delegate_email_batches(entry.id, self.course.id, task_input, "action_name")  # pylint: disable=no-member
Ejemplo n.º 3
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(course_id=SlashSeparatedCourseKey("bogus", "course", "id"), to_option=SEND_TO_ALL)
     email.save()
     entry = InstructorTask.create(self.course.id, "task_type", "task_key", "task_input", self.instructor)
     task_input = {"email_id": email.id}  # pylint: disable=no-member
     with self.assertRaisesRegexp(ValueError, 'does not match email value'):
         perform_delegate_email_batches(entry.id, self.course.id, task_input, "action_name")  # pylint: disable=no-member
Ejemplo n.º 4
0
 def test_wrong_course_id_in_task(self):
     """
     Tests exception when the course_id in task is not the same as one explicitly passed in.
     """
     email = CourseEmail(course_id=self.course.id, to_option=SEND_TO_ALL)
     email.save()
     entry = InstructorTask.create("bogus/task/id", "task_type", "task_key", "task_input", self.instructor)
     task_input = {"email_id": email.id}  # pylint: disable=E1101
     with self.assertRaisesRegexp(ValueError, "does not match task value"):
         perform_delegate_email_batches(entry.id, self.course.id, task_input, "action_name")  # pylint: disable=E1101
 def test_nonexist_course(self, mock_log):
     """
     Tests exception when the course in the email doesn't exist
     """
     email = CourseEmail(course_id="I/DONT/EXIST")
     email.save()
     delegate_email_batches.delay(email.id, self.instructor.id)
     ((log_str, _), _) = mock_log.exception.call_args
     self.assertTrue(mock_log.exception.called)
     self.assertIn('get_course_by_id failed:', log_str)
Ejemplo n.º 6
0
 def test_wrong_course_id_in_task(self):
     """
     Tests exception when the course_id in task is not the same as one explicitly passed in.
     """
     email = CourseEmail(course_id=self.course.id, to_option=SEND_TO_ALL)
     email.save()
     entry = InstructorTask.create("bogus/task/id", "task_type", "task_key", "task_input", self.instructor)
     task_input = {"email_id": email.id}
     with self.assertRaisesRegexp(ValueError, 'does not match task value'):
         perform_delegate_email_batches(entry.id, self.course.id, task_input, "action_name")
Ejemplo n.º 7
0
 def test_nonexist_to_option(self, mock_log):
     """
     Tests exception when the to_option in the email doesn't exist
     """
     email = CourseEmail(course_id=self.course.id, to_option="IDONTEXIST")
     email.save()
     delegate_email_batches.delay(email.id, self.instructor.id)
     ((log_str, opt_str), _) = mock_log.error.call_args
     self.assertTrue(mock_log.error.called)
     self.assertIn('Unexpected bulk email TO_OPTION found', log_str)
     self.assertEqual("IDONTEXIST", opt_str)
Ejemplo n.º 8
0
 def test_nonexistent_course(self):
     """
     Tests exception when the course in the email doesn't exist
     """
     course_id = "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}  # pylint: disable=E1101
     with self.assertRaisesRegexp(ValueError, "Course not found"):
         perform_delegate_email_batches(entry.id, course_id, task_input, "action_name")  # pylint: disable=E1101
 def test_nonexist_to_option(self, mock_log):
     """
     Tests exception when the to_option in the email doesn't exist
     """
     email = CourseEmail(course_id=self.course.id, to_option="IDONTEXIST")
     email.save()
     delegate_email_batches.delay(email.id, self.instructor.id)
     ((log_str, opt_str), _) = mock_log.error.call_args
     self.assertTrue(mock_log.error.called)
     self.assertIn('Unexpected bulk email TO_OPTION found', log_str)
     self.assertEqual("IDONTEXIST", opt_str)
Ejemplo n.º 10
0
 def test_nonexistent_course(self):
     """
     Tests exception when the course in the email doesn't exist
     """
     course_id = SlashSeparatedCourseKey("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}  # pylint: disable=no-member
     # (?i) is a regex for ignore case
     with self.assertRaisesRegexp(ValueError, r"(?i)course not found"):
         perform_delegate_email_batches(entry.id, course_id, task_input, "action_name")  # pylint: disable=no-member
Ejemplo n.º 11
0
 def test_nonexistent_course(self):
     """
     Tests exception when the course in the email doesn't exist
     """
     course_id = "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}  # pylint: disable=E1101
     with self.assertRaisesRegexp(ValueError, "Course not found"):
         perform_delegate_email_batches(entry.id, course_id, task_input,
                                        "action_name")  # pylint: disable=E1101