'Given that I have a user who has not passed course
If I run regeneration for that user
Then certificate generation will be not be requested'

@override_settings(CERT_QUEUE='test-queue')
@patch('capa.xqueue_interface.XQueueInterface.send_to_queue', spec=True)
def test_regenerating_certificate(self, mock_send_to_queue):

    key = self.course.location.course_key
    self._create_cert(key, self.user, CertificateStatuses.downloadable)
    self._run_command(username=self.user.email, course=unicode(key), noop=False, insecure=True, template_file=None, grade_value=None)
    certificate = GeneratedCertificate.eligible_certificates.get(user=self.user, course_id=key)
    self.assertEqual(certificate.status, CertificateStatuses.notpassing)
    self.assertFalse(mock_send_to_queue.called)
