'Test that any grading errors are properly reported in the
progress dict and uploaded to the report store.'

@patch('lms.djangoapps.instructor_task.tasks_helper.runner._get_current_task')
@patch('lms.djangoapps.grades.new.course_grade_factory.CourseGradeFactory.iter')
def test_grading_failure(self, mock_grades_iter, _mock_current_task):

    mock_grades_iter.return_value = [(self.create_student('username', 'student@example.com'), None, TypeError('Cannot    grade    student'))]
    result = CourseGradeReport.generate(None, None, self.course.id, None, 'graded')
    self.assertDictContainsSubset({'attempted': 1, 'succeeded': 0, 'failed': 1}, result)
    report_store = ReportStore.from_config(config_name='GRADES_DOWNLOAD')
    self.assertTrue(any((('grade_report_err' in item[0]) for item in report_store.links_for(self.course.id))))
