'Test that celery handles throttling failures by retrying.'

def _test_retry_after_unlimited_retry_error(self, exception):

    num_emails = 8
    self._create_students((num_emails - 1))
    expected_fails = 0
    expected_succeeds = num_emails
    expected_retries = 10
    with patch('bulk_email.tasks.get_connection', autospec=True) as get_conn:
        get_conn.return_value.send_messages.side_effect = cycle(chain(repeat(exception, expected_retries), [None]))
        self._test_run_with_task(send_bulk_course_email, 'emailed', num_emails, expected_succeeds, failed=expected_fails, retried_nomax=(expected_retries * num_emails))
