'Test that exceptions are handled well'

def test_raising_exception_in_auto_registration_and_enrollment_case(self):

    csv_content = 'test_student1@example.com,test_student_1,tester1,USA\ntest_student2@example.com,test_student_1,tester2,US'
    uploaded_file = SimpleUploadedFile('temp.csv', csv_content)
    with patch('lms.djangoapps.instructor.views.api.create_manual_course_enrollment') as mock:
        mock.side_effect = NonExistentCourseError()
        response = self.client.post(self.url, {'students_list': uploaded_file})
    self.assertEqual(response.status_code, 200)
    data = json.loads(response.content)
    self.assertNotEquals(len(data['row_errors']), 0)
    self.assertEquals(data['row_errors'][0]['response'], 'NonExistentCourseError')
    manual_enrollments = ManualEnrollmentAudit.objects.all()
    self.assertEqual(manual_enrollments.count(), 0)
