Esempio 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)
 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)
Esempio n. 3
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)
Esempio n. 4
0
 def test_nonexist_email(self, mock_log, retry, result):
     """
     Tests retries when the email doesn't exist
     """
     delegate_email_batches.delay(-1, self.instructor.id)
     ((log_str, email_id, num_retries), _) = mock_log.warning.call_args
     self.assertTrue(mock_log.warning.called)
     self.assertIn('Failed to get CourseEmail with id', log_str)
     self.assertEqual(email_id, -1)
     self.assertTrue(retry.called)
     self.assertFalse(result.called)
 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)
 def test_nonexist_email(self, mock_log, retry, result):
     """
     Tests retries when the email doesn't exist
     """
     delegate_email_batches.delay(-1, self.instructor.id)
     ((log_str, email_id, _num_retries), _) = mock_log.warning.call_args
     self.assertTrue(mock_log.warning.called)
     self.assertIn('Failed to get CourseEmail with id', log_str)
     self.assertEqual(email_id, -1)
     self.assertTrue(retry.called)
     self.assertFalse(result.called)