コード例 #1
0
def create_tenant(name):
    """ Create a tenant via cli, record its id and token for further use.  """
    cli = CliTenantadm()
    api = ApiClient(tenantadm.URL_INTERNAL)

    id = cli.create_tenant(name)

    page = 0
    per_page = 20
    qs_params = {}
    found = None
    while True:
        page = page + 1
        qs_params['page'] = page
        qs_params['per_page'] = per_page
        r = api.call('GET',
                     tenantadm.URL_INTERNAL_TENANTS,
                     qs_params=qs_params)
        assert r.status_code == 200
        api_tenants = r.json()

        found = [at for at in api_tenants if at['id'] == id]
        if len(found) > 0:
            break

        if len(api_tenants) == 0:
            break

    assert len(found) == 1
    token = found[0]['tenant_token']

    return Tenant(name, id, token)
コード例 #2
0
def tenants_users(clean_migrated_mongo_mt):
    cli = CliTenantadm()
    api = ApiClient(tenantadm.URL_INTERNAL)

    names = ['tenant1', 'tenant2']
    tenants=[]

    for n in names:
        tenants.append(create_tenant(n))

    for t in tenants:
        for i in range(2):
            user = create_tenant_user(i, t)
            t.users.append(user)

    yield tenants
コード例 #3
0
ファイル: common.py プロジェクト: synapticon/integration
def create_tenant(name):
    """ Create a tenant via cli, record its id and token for further use.  """
    cli = CliTenantadm()
    api = ApiClient(tenantadm.URL_INTERNAL)

    id = cli.create_tenant(name)

    r = api.call('GET', tenantadm.URL_INTERNAL_TENANTS)
    assert r.status_code == 200

    api_tenants = r.json()

    api_tenant = [at for at in api_tenants if at['id'] == id]
    token = api_tenant[0]['tenant_token']

    return Tenant(name, id, token)
コード例 #4
0
def tenants(mongo):
    cli = CliTenantadm()
    api = ApiClient(tenantadm.URL_INTERNAL)

    tenants = [Tenant('tenant1'), Tenant('tenant2')]

    for t in tenants:
        t.id = cli.create_tenant(t.name)

    r = api.call('GET', tenantadm.URL_INTERNAL_TENANTS)
    api_tenants = r.json()

    for t in tenants:
        api_tenant = [at for at in api_tenants if at['id'] == t.id]
        t.tenant_token = api_tenant[0]['tenant_token']

    yield tenants
    mongo_cleanup(mongo)