@pytest.fixture(scope='module')
def account(api, storage_cluster):
    'Get account.\n\n    :param api: ambra api\n    :param storage_cluster: storage cluster\n\n    :yields: test account\n\n    :raises RuntimeError: On deleted account with existing studies\n    :raises TimeoutError: Time for waiting account deletion is out\n    '
    account_name = settings.TEST_ACCOUNT_NAME
    if storage_cluster:
        account_name = '{account}_{cluster}'.format(account=account_name, cluster=storage_cluster.name)
    try:
        (account, user) = create_account(api, account_name)
    except DuplicateName:
        logger.error('Duplicated account: %s', account_name)
        account = api.Account.list().filter_by(Filter('name', FilterCondition.equals, account_name)).first()
        if (account is None):
            raise RuntimeError('Account duplicated but not exists')
        clear_studies(api, account)
        delete_account(api, account)
        (account, user) = create_account(api, account_name)
    if (storage_cluster is not None):
        QueryO(api=api, url='/cluster/account/bind', request_data={'account_id': account.uuid, 'cluster_id': storage_cluster.uuid}, errors_mapping={}, required_sid=True).get()
        logger.info('Bind account to storage cluster {name}'.format(name=storage_cluster.name))
    (yield UserParams(account=account, user=user))
    delete_account(api, account)
    start = monotonic()
    while True:
        if ((monotonic() - start) >= settings.API['account_deletion_timeout']):
            raise TimeoutError('Account still exists')
        account = api.Account.list().filter_by(Filter('name', FilterCondition.equals, account_name)).first()
        if (account is None):
            return
        sleep(settings.API['account_deletion_check_interval'])
Get account.

:param api: ambra api
:param storage_cluster: storage cluster

:yields: test account

:raises RuntimeError: On deleted account with existing studies
:raises TimeoutError: Time for waiting account deletion is out
@pytest.fixture(scope='module')
def account(api, storage_cluster):
    'Get account.\n\n    :param api: ambra api\n    :param storage_cluster: storage cluster\n\n    :yields: test account\n\n    :raises RuntimeError: On deleted account with existing studies\n    :raises TimeoutError: Time for waiting account deletion is out\n    '
    account_name = settings.TEST_ACCOUNT_NAME
    if storage_cluster:
        account_name = '{account}_{cluster}'.format(account=account_name, cluster=storage_cluster.name)
    try:
        (account, user) = create_account(api, account_name)
    except DuplicateName:
        logger.error('Duplicated account: %s', account_name)
        account = api.Account.list().filter_by(Filter('name', FilterCondition.equals, account_name)).first()
        if (account is None):
            raise RuntimeError('Account duplicated but not exists')
        clear_studies(api, account)
        delete_account(api, account)
        (account, user) = create_account(api, account_name)
    if (storage_cluster is not None):
        QueryO(api=api, url='/cluster/account/bind', request_data={'account_id': account.uuid, 'cluster_id': storage_cluster.uuid}, errors_mapping={}, required_sid=True).get()
        logger.info('Bind account to storage cluster {name}'.format(name=storage_cluster.name))
    (yield UserParams(account=account, user=user))
    delete_account(api, account)
    start = monotonic()
    while True:
        if ((monotonic() - start) >= settings.API['account_deletion_timeout']):
            raise TimeoutError('Account still exists')
        account = api.Account.list().filter_by(Filter('name', FilterCondition.equals, account_name)).first()
        if (account is None):
            return
        sleep(settings.API['account_deletion_check_interval'])