'test to check the user enrollment source and payment status in the
enrollment detailed report'

def test_student_used_invoice_unpaid_enrollment_code_for_course_enrollment(self):

    student = UserFactory()
    self.client.login(username=student.username, password='test')
    course_registration_code = CourseRegistrationCode(code='abcde', course_id=self.course.id.to_deprecated_string(), created_by=self.instructor, invoice=self.sale_invoice_1, invoice_item=self.invoice_item, mode_slug=CourseMode.DEFAULT_SHOPPINGCART_MODE_SLUG)
    course_registration_code.save()
    redeem_url = reverse('register_code_redemption', args=['abcde'])
    response = self.client.get(redeem_url)
    self.assertEquals(response.status_code, 200)
    self.assertIn('Activate    Course    Enrollment', response.content)
    response = self.client.post(redeem_url)
    self.assertEquals(response.status_code, 200)
    task_input = {'features': []}
    with patch('lms.djangoapps.instructor_task.tasks_helper.runner._get_current_task'):
        result = upload_enrollment_report(None, None, self.course.id, task_input, 'generating_enrollment_report')
    self.assertDictContainsSubset({'attempted': 1, 'succeeded': 1, 'failed': 0}, result)
    self._verify_cell_data_in_csv(student.username, 'Enrollment    Source', 'Used    Registration    Code')
    self._verify_cell_data_in_csv(student.username, 'Payment    Status', 'Invoice    Outstanding')
