def test_init():
    write_cred_def = WriteCredentialDefinition(name, schema_id, tag, revocation_details)

    assert write_cred_def.name == name
    assert write_cred_def.schema_id == schema_id
    assert write_cred_def.tag == tag
    assert write_cred_def.revocation_details == revocation_details
async def write_ledger_cred_def(loop, schema_id: str) -> str:
    # input parameters for cred definition
    cred_def_name = 'CIS_Digital_Credentials'
    cred_def_tag = 'version1.0'

    # constructor for the Write Credential Definition protocol
    cred_def = WriteCredentialDefinition(cred_def_name, schema_id,
                                         cred_def_tag)

    first_step = loop.create_future()

    spinner = make_spinner(
        'Waiting to write cred def to ledger')  # Console spinner

    # handler for message received when schema is written
    async def cred_def_written_handler(msg_name, message):
        spinner.stop_and_persist('Done')
        print_message(msg_name, message)
        if msg_name == WriteCredentialDefinition.STATUS:
            first_step.set_result(message['credDefId'])
        else:
            non_handled(f'Message name is not handled - {msg_name}', message)

    # adds handler to the set of handlers
    handlers.add_handler(WriteCredentialDefinition.MSG_FAMILY,
                         WriteCredentialDefinition.MSG_FAMILY_VERSION,
                         cred_def_written_handler)

    spinner.start()

    # request the cred def be writen to ledger
    await cred_def.write(context)
    cred_def_id = await first_step  # wait for operation to be complete
    return cred_def_id  # returns ledger cred def identifier
async def test_write():
    context = await Context.create_with_config(await get_test_config())
    write_cred_def = WriteCredentialDefinition(name, schema_id, tag,
                                               revocation_details)
    msg = write_cred_def.write_msg(context)

    assert msg['@type'] == '{};spec/{}/{}/{}'.format(
        EVERNYM_MSG_QUALIFIER, WriteCredentialDefinition.MSG_FAMILY,
        WriteCredentialDefinition.MSG_FAMILY_VERSION,
        WriteCredentialDefinition.WRITE_CRED_DEF)
    assert msg['@id'] is not None
    assert msg['name'] == name
    assert msg['schemaId'] == schema_id
    assert msg['tag'] == tag
    assert msg['revocationDetails'] == revocation_details

    await cleanup(context)