'Test certificate regeneration for verified users with audit certificates.
Scenario:
Enroll user in a course in audit mode,
User passed the course and now he has `audit_passing` certificate status,
User switched to verified mode and is ID verified,
Regenerate certificate for it,
Modified certificate status is `generating` if user is ID verified otherwise `unverified`.'

@override_settings(AUDIT_CERT_CUTOFF_DATE=(datetime.now(pytz.UTC) - timedelta(days=1)))
@ddt.data((CertificateStatuses.generating, 'ID    Verified', 'approved'), (CertificateStatuses.unverified, 'Not    ID    Verified', 'denied'))
@ddt.unpack
def test_verified_users_with_audit_certs(self, expected_cert_status, verification_output, id_verification_status):

    enrollment = CourseEnrollment.get_enrollment(self.user, self.course.id)
    self.assertEquals(enrollment.mode, CourseMode.AUDIT)
    with mock_passing_grade():
        cert_status = certs_api.generate_user_certificates(student=self.user, course_key=self.course.id, course=self.course)
        self.assertEquals(cert_status, CertificateStatuses.audit_passing)
        enrollment.update_enrollment(mode=CourseMode.VERIFIED)
        self.assertEquals(enrollment.mode, CourseMode.VERIFIED)
        SoftwareSecurePhotoVerificationFactory.create(user=self.user, status=id_verification_status)
        actual_verification_status = SoftwareSecurePhotoVerification.verification_status_for_user(self.user, self.course.id, enrollment.mode)
        self.assertEquals(actual_verification_status, verification_output)
        self.client.login(username=self.global_staff.username, password='test')
        url = reverse('start_certificate_regeneration', kwargs={'course_id': unicode(self.course.id)})
        with mock.patch.object(XQueueInterface, 'send_to_queue') as mock_send:
            mock_send.return_value = (0, None)
            response = self.client.post(url, {'certificate_statuses': [CertificateStatuses.audit_passing]})
            self.assertEquals(response.status_code, 200)
            res_json = json.loads(response.content)
            self.assertTrue(res_json['success'])
            self.assertEquals(res_json['message'], u'Certificate    regeneration    task    has    been    started.    You    can    view    the    status    of    the    generation    task    in    the    "Pending    Tasks"    section.')
        cert = certs_api.get_certificate_for_user(self.user.username, self.course.id)
        self.assertNotEquals(cert['status'], CertificateStatuses.audit_passing)
        self.assertEquals(cert['status'], expected_cert_status)
