'Create a fake certificate for a user.
Arguments:
username (unicode): Identifier for the certificate\'s user.
course_key (unicode): Identifier for the certificate\'s course.
Keyword Arguments:
cert_mode (str): The mode of the certificate (e.g "honor")
status (str): The status of the certificate (e.g. "downloadable")
grade (str): The grade of the certificate (e.g "0.89" for 89%)
Raises:
CommandError'

def handle(self, *args, **options):

    if (len(args) < 2):
        raise CommandError(self.USAGE)
    user = User.objects.get(username=args[0])
    course_key = CourseKey.from_string(args[1])
    cert_mode = options.get('cert_mode', 'honor')
    status = options.get('status', CertificateStatuses.downloadable)
    grade = options.get('grade', '')
    (cert, created) = GeneratedCertificate.eligible_certificates.get_or_create(user=user, course_id=course_key)
    cert.mode = cert_mode
    cert.status = status
    cert.grade = grade
    if (status == CertificateStatuses.downloadable):
        cert.download_uuid = 'test'
        cert.verify_uuid = 'test'
        cert.download_url = 'http://www.example.com'
    cert.save()
    if created:
        LOGGER.info(u'Created    certificate    for    user    %s    in    course    %s    with    mode    %s,    status    %s,    and    grade    %s', user.id, unicode(course_key), cert_mode, status, grade)
    else:
        LOGGER.info(u'Updated    certificate    for    user    %s    in    course    %s    with    mode    %s,    status    %s,    and    grade    %s', user.id, unicode(course_key), cert_mode, status, grade)
