'Test handling of error retrieving email'

def test_list_email_content_error(self, task_history_request):

    invalid_task = FakeContentTask(0, 0, 0, 'test')
    invalid_task.make_invalid_input()
    task_history_request.return_value = [invalid_task]
    url = reverse('list_email_content', kwargs={'course_id': self.course.id.to_deprecated_string()})
    response = self.client.post(url, {})
    self.assertEqual(response.status_code, 200)
    self.assertTrue(task_history_request.called)
    returned_email_info = json.loads(response.content)['emails']
    self.assertEqual(len(returned_email_info), 1)
    returned_info = returned_email_info[0]
    for info in ['created', 'sent_to', 'email', 'number_sent', 'requester']:
        self.assertEqual(returned_info[info], None)
