|
| 1 | +import pytest |
| 2 | + |
| 3 | +from databricks.sdk.core import DatabricksError |
| 4 | + |
| 5 | + |
| 6 | +def test_filtering_groups(w, random): |
| 7 | + all = w.groups.list(filter=f'displayName eq any-{random(12)}') |
| 8 | + found = len(list(all)) |
| 9 | + assert found == 0 |
| 10 | + |
| 11 | + |
| 12 | +def test_scim_error_unmarshall(w, random): |
| 13 | + with pytest.raises(DatabricksError) as exc_info: |
| 14 | + w.groups.list(filter=random(12)) |
| 15 | + assert 'Given filter operator is not supported' in str(exc_info.value) |
| 16 | + |
| 17 | + |
| 18 | +@pytest.mark.parametrize( |
| 19 | + "path,call", |
| 20 | + [("/api/2.0/preview/scim/v2/Users", lambda w: w.users.list(count=10)), |
| 21 | + ("/api/2.0/preview/scim/v2/Groups", lambda w: w.groups.list(count=4)), |
| 22 | + ("/api/2.0/preview/scim/v2/ServicePrincipals", lambda w: w.service_principals.list(count=1)), ]) |
| 23 | +def test_workspace_users_list_pagination(w, path, call): |
| 24 | + raw = w.api_client.do('GET', path) |
| 25 | + total = raw['totalResults'] |
| 26 | + all = call(w) |
| 27 | + found = len(list(all)) |
| 28 | + assert found == total |
| 29 | + |
| 30 | + |
| 31 | +@pytest.mark.parametrize( |
| 32 | + "path,call", |
| 33 | + [("/api/2.0/accounts/%s/scim/v2/Users", lambda a: a.users.list(count=3000)), |
| 34 | + ("/api/2.0/accounts/%s/scim/v2/Groups", lambda a: a.groups.list(count=5)), |
| 35 | + ("/api/2.0/accounts/%s/scim/v2/ServicePrincipals", lambda a: a.service_principals.list(count=1000)), ]) |
| 36 | +def test_account_users_list_pagination(a, path, call): |
| 37 | + raw = a.api_client.do('GET', path.replace("%s", a.config.account_id)) |
| 38 | + total = raw['totalResults'] |
| 39 | + all = call(a) |
| 40 | + found = len(list(all)) |
| 41 | + assert found == total |
0 commit comments