'Verify that certificates are generated only for those students
who do not have `downloadable` or `generating` certificates.'

@ddt.data((CertificateStatuses.downloadable, 2), (CertificateStatuses.generating, 2), (CertificateStatuses.notpassing, 4), (CertificateStatuses.audit_passing, 4))
@ddt.unpack
def test_certificate_generation_whitelisted_not_generated(self, status, expected_certs):

    students = self._create_students(5)
    for student in students[:2]:
        GeneratedCertificateFactory.create(user=student, course_id=self.course.id, status=status)
    for student in students[:4]:
        CertificateWhitelistFactory.create(user=student, course_id=self.course.id, whitelist=True)
    task_input = {'student_set': 'whitelisted_not_generated'}
    expected_results = {'action_name': 'certificates    generated', 'total': expected_certs, 'attempted': expected_certs, 'succeeded': expected_certs, 'failed': 0, 'skipped': 0}
    self.assertCertificatesGenerated(task_input, expected_results)
    for student in students[:4]:
        self.assertIn(GeneratedCertificate.certificate_for_student(student, self.course.id).status, CertificateStatuses.PASSED_STATUSES)
    self.assertIsNone(GeneratedCertificate.certificate_for_student(students[4], self.course.id))
