Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmay-db committed Dec 12, 2024
1 parent 5de2bc7 commit b30571e
Showing 1 changed file with 21 additions and 27 deletions.
48 changes: 21 additions & 27 deletions tests/test_iam.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
import pytest

from databricks.sdk import WorkspaceClient, AccountClient
from databricks.sdk import AccountClient, WorkspaceClient


@pytest.mark.parametrize(
"path,call",
[
("/api/2.0/preview/scim/v2/Users", lambda w: w.users.list()),
("/api/2.0/preview/scim/v2/Groups", lambda w: w.groups.list()),
("/api/2.0/preview/scim/v2/ServicePrincipals", lambda w: w.service_principals.list()),
],
"path,call", [("/api/2.0/preview/scim/v2/Users", lambda w: w.users.list()),
("/api/2.0/preview/scim/v2/Groups", lambda w: w.groups.list()),
("/api/2.0/preview/scim/v2/ServicePrincipals", lambda w: w.service_principals.list()), ],
)
def test_workspace_iam_list(config, requests_mock, path, call):
requests_mock.get(
f"http://localhost{path}",
request_headers={
"Accept": "application/json",
},
text="null",
)
requests_mock.get(f"http://localhost{path}",
request_headers={
"Accept": "application/json",
},
text="null",
)
w = WorkspaceClient(config=config)
for _ in call(w):
pass
Expand All @@ -27,23 +24,20 @@ def test_workspace_iam_list(config, requests_mock, path, call):

@pytest.mark.parametrize(
"path,call",
[
("/api/2.0/accounts/%s/scim/v2/Users", lambda a: a.users.list()),
("/api/2.0/accounts/%s/scim/v2/Groups", lambda a: a.groups.list()),
("/api/2.0/accounts/%s/scim/v2/ServicePrincipals", lambda a: a.service_principals.list()),
],
[("/api/2.0/accounts/%s/scim/v2/Users", lambda a: a.users.list()),
("/api/2.0/accounts/%s/scim/v2/Groups", lambda a: a.groups.list()),
("/api/2.0/accounts/%s/scim/v2/ServicePrincipals", lambda a: a.service_principals.list()), ],
)
def test_account_iam_list(config, requests_mock, path, call):
config.account_id = "test_account_id"
requests_mock.get(
path.replace("%s", config.account_id),
request_headers={
"Accept": "application/json",
},
text="null",
)
requests_mock.get(path.replace("%s", config.account_id),
request_headers={
"Accept": "application/json",
},
text="null",
)
a = AccountClient(config=config)
for _ in call(a):
pass
assert requests_mock.call_count == 1
assert requests_mock.called
assert requests_mock.called

0 comments on commit b30571e

Please sign in to comment.