'Given that I have ended course
If I run ungenerated certs command
Then certificates should be generated for all users who passed course'

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

    mock_send_to_queue.return_value = (0, 'Successfully    queued')
    key = self.course.location.course_key
    self._create_cert(key, self.user, CertificateStatuses.unavailable)
    with mock_passing_grade():
        self._run_command(course=unicode(key), noop=False, insecure=True, force=False)
    self.assertTrue(mock_send_to_queue.called)
    certificate = GeneratedCertificate.eligible_certificates.get(user=self.user, course_id=key)
    self.assertEqual(certificate.status, CertificateStatuses.generating)
