Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added workspace_group_name and account_group_name to make_ucx_group fixture #664

Merged
merged 2 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import collections
import functools
import logging
import random
from datetime import timedelta
from functools import partial

Expand Down Expand Up @@ -90,21 +89,16 @@ def sql_fetch_all(sql_backend):


@pytest.fixture
def user_pool(ws):
return list(ws.users.list(filter="displayName sw 'test-user-'", attributes="id, userName, displayName"))


@pytest.fixture
def make_ucx_group(make_random, make_group, make_acc_group, user_pool):
assert (
len(user_pool) >= 1
), "must have 'test-user-*' test users with id, userName and displayName in your test workspace"

def inner():
display_name = f"ucx_{make_random(4)}"
members = [_.id for _ in random.choices(user_pool, k=random.randint(1, 40))]
ws_group = make_group(display_name=display_name, members=members, entitlements=["allow-cluster-create"])
acc_group = make_acc_group(display_name=display_name, members=members)
def make_ucx_group(make_random, make_group, make_acc_group, make_user):
def inner(workspace_group_name=None, account_group_name=None):
if not workspace_group_name:
workspace_group_name = f"ucx_{make_random(4)}"
if not account_group_name:
account_group_name = workspace_group_name
user = make_user()
members = [user.id]
ws_group = make_group(display_name=workspace_group_name, members=members, entitlements=["allow-cluster-create"])
acc_group = make_acc_group(display_name=account_group_name, members=members)
return ws_group, acc_group

return inner
Expand Down
11 changes: 8 additions & 3 deletions tests/integration/test_conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
def test_make_ucx_group(make_ucx_group):
ws_group_a, acc_group_a = make_ucx_group()
assert ws_group_a is not None
assert acc_group_a is not None
ws, acc = make_ucx_group()
assert ws is not None
assert acc is not None


def test_make_ucx_group_with_names(make_ucx_group, make_random):
ws, acc = make_ucx_group(workspace_group_name=f"foo_{make_random(4)}", account_group_name=f"bar_{make_random(4)}")
assert ws.display_name != acc.display_name
Loading