Add service principal resource #1836
102 tests run, 0 skipped, 7 failed.
Annotations
Check failure on line 80 in aws-lambda/tests/resources/service_principals/test_service_principal.py
github-actions / JUnit Test Report
test_service_principal.test_create_or_update_service_principal_update
AttributeError: Mock object has no attribute 'service_principals'
Raw output
patched_get_service_principal = <MagicMock name='get_service_principal' id='140250912688128'>
patched_create_service_principal = <MagicMock name='create_service_principal' id='140250912840480'>
patched_update_service_principal = <MagicMock name='update_service_principal' id='140250912839520'>
patched_get_workspace_client = <MagicMock name='get_workspace_client' id='140250929388176'>
workspace_client = <MagicMock name='get_workspace_client()' spec='WorkspaceClient' id='140250912694512'>
@patch("databricks_cdk.resources.service_principals.service_principal.get_workspace_client")
@patch("databricks_cdk.resources.service_principals.service_principal.update_service_principal")
@patch("databricks_cdk.resources.service_principals.service_principal.create_service_principal")
@patch("databricks_cdk.resources.service_principals.service_principal.get_service_principal")
def test_create_or_update_service_principal_update(
patched_get_service_principal,
patched_create_service_principal,
patched_update_service_principal,
patched_get_workspace_client,
workspace_client
):
patched_get_workspace_client.return_value = workspace_client
mock_physical_resource_id = "some_id"
existing_service_principal = ServicePrincipal(
active=True,
display_name="mock_name",
id=mock_physical_resource_id,
roles=[ComplexValue(value="role")],
)
> workspace_client.service_principals.get.return_value = existing_service_principal
tests/resources/service_principals/test_service_principal.py:80:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MagicMock name='get_workspace_client()' spec='WorkspaceClient' id='140250912694512'>
name = 'service_principals'
def __getattr__(self, name):
if name in {'_mock_methods', '_mock_unsafe'}:
raise AttributeError(name)
elif self._mock_methods is not None:
if name not in self._mock_methods or name in _all_magics:
> raise AttributeError("Mock object has no attribute %r" % name)
E AttributeError: Mock object has no attribute 'service_principals'
/opt/hostedtoolcache/Python/3.12.8/x64/lib/python3.12/unittest/mock.py:660: AttributeError
Check failure on line 116 in aws-lambda/tests/resources/service_principals/test_service_principal.py
github-actions / JUnit Test Report
test_service_principal.test_get_service_principal
AttributeError: Mock object has no attribute 'service_principals'
Raw output
workspace_client = <MagicMock spec='WorkspaceClient' id='140250912876416'>
def test_get_service_principal(workspace_client):
service_principal = ServicePrincipal(
active=True,
display_name="mock_name",
id="some_id",
)
> workspace_client.service_principals.get.return_value = service_principal
tests/resources/service_principals/test_service_principal.py:116:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MagicMock spec='WorkspaceClient' id='140250912876416'>
name = 'service_principals'
def __getattr__(self, name):
if name in {'_mock_methods', '_mock_unsafe'}:
raise AttributeError(name)
elif self._mock_methods is not None:
if name not in self._mock_methods or name in _all_magics:
> raise AttributeError("Mock object has no attribute %r" % name)
E AttributeError: Mock object has no attribute 'service_principals'
/opt/hostedtoolcache/Python/3.12.8/x64/lib/python3.12/unittest/mock.py:660: AttributeError
Check failure on line 124 in aws-lambda/tests/resources/service_principals/test_service_principal.py
github-actions / JUnit Test Report
test_service_principal.test_get_service_principal_error
AttributeError: Mock object has no attribute 'service_principals'
Raw output
workspace_client = <MagicMock spec='WorkspaceClient' id='140250912868112'>
def test_get_service_principal_error(workspace_client):
> workspace_client.service_principals.get.side_effect = NotFound("Not found")
tests/resources/service_principals/test_service_principal.py:124:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MagicMock spec='WorkspaceClient' id='140250912868112'>
name = 'service_principals'
def __getattr__(self, name):
if name in {'_mock_methods', '_mock_unsafe'}:
raise AttributeError(name)
elif self._mock_methods is not None:
if name not in self._mock_methods or name in _all_magics:
> raise AttributeError("Mock object has no attribute %r" % name)
E AttributeError: Mock object has no attribute 'service_principals'
/opt/hostedtoolcache/Python/3.12.8/x64/lib/python3.12/unittest/mock.py:660: AttributeError
Check failure on line 138 in aws-lambda/tests/resources/service_principals/test_service_principal.py
github-actions / JUnit Test Report
test_service_principal.test_create_service_principle
AttributeError: Mock object has no attribute 'service_principals'
Raw output
workspace_client = <MagicMock spec='WorkspaceClient' id='140250913025936'>
def test_create_service_principle(workspace_client):
mock_properties = ServicePrincipalProperties(
workspace_url="https://test.cloud.databricks.com",
service_principal=ServicePrincipal(
active=True,
display_name="mock_name",
),
)
> workspace_client.service_principals.create.return_value = ServicePrincipal(
active=True,
display_name="mock_name",
id="some_id",
)
tests/resources/service_principals/test_service_principal.py:138:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MagicMock spec='WorkspaceClient' id='140250913025936'>
name = 'service_principals'
def __getattr__(self, name):
if name in {'_mock_methods', '_mock_unsafe'}:
raise AttributeError(name)
elif self._mock_methods is not None:
if name not in self._mock_methods or name in _all_magics:
> raise AttributeError("Mock object has no attribute %r" % name)
E AttributeError: Mock object has no attribute 'service_principals'
/opt/hostedtoolcache/Python/3.12.8/x64/lib/python3.12/unittest/mock.py:660: AttributeError
Check failure on line 168 in aws-lambda/tests/resources/service_principals/test_service_principal.py
github-actions / JUnit Test Report
test_service_principal.test_create_service_principal_error
AttributeError: Mock object has no attribute 'service_principals'
Raw output
workspace_client = <MagicMock spec='WorkspaceClient' id='140250913014992'>
def test_create_service_principal_error(workspace_client):
mock_properties = ServicePrincipalProperties(
workspace_url="https://test.cloud.databricks.com",
service_principal=ServicePrincipal(
active=True,
display_name="mock_name",
),
)
> workspace_client.service_principals.create.return_value = ServicePrincipal(
active=True,
display_name="mock_name",
id=None,
)
tests/resources/service_principals/test_service_principal.py:168:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MagicMock spec='WorkspaceClient' id='140250913014992'>
name = 'service_principals'
def __getattr__(self, name):
if name in {'_mock_methods', '_mock_unsafe'}:
raise AttributeError(name)
elif self._mock_methods is not None:
if name not in self._mock_methods or name in _all_magics:
> raise AttributeError("Mock object has no attribute %r" % name)
E AttributeError: Mock object has no attribute 'service_principals'
/opt/hostedtoolcache/Python/3.12.8/x64/lib/python3.12/unittest/mock.py:660: AttributeError
Check failure on line 188 in aws-lambda/tests/resources/service_principals/test_service_principal.py
github-actions / JUnit Test Report
test_service_principal.test_update_service_principal
AttributeError: Mock object has no attribute 'service_principals'
Raw output
workspace_client = <MagicMock spec='WorkspaceClient' id='140250912867680'>
def test_update_service_principal(workspace_client):
mock_properties = ServicePrincipalProperties(
workspace_url="https://test.cloud.databricks.com",
service_principal=ServicePrincipal(
active=True,
display_name="mock_name",
id="some_id",
roles=[ComplexValue(value="role")],
),
)
> workspace_client.service_principals.update.return_value = ServicePrincipal(
active=True,
display_name="mock_name",
id="some_id",
roles=[ComplexValue(value="role")],
)
tests/resources/service_principals/test_service_principal.py:188:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MagicMock spec='WorkspaceClient' id='140250912867680'>
name = 'service_principals'
def __getattr__(self, name):
if name in {'_mock_methods', '_mock_unsafe'}:
raise AttributeError(name)
elif self._mock_methods is not None:
if name not in self._mock_methods or name in _all_magics:
> raise AttributeError("Mock object has no attribute %r" % name)
E AttributeError: Mock object has no attribute 'service_principals'
/opt/hostedtoolcache/Python/3.12.8/x64/lib/python3.12/unittest/mock.py:660: AttributeError
Check failure on line 222 in aws-lambda/tests/resources/service_principals/test_service_principal.py
github-actions / JUnit Test Report
test_service_principal.test_delete_service_principal
AttributeError: Mock object has no attribute 'service_principals'
Raw output
patched_get_workspace_client = <MagicMock name='get_workspace_client' id='140250912867872'>
workspace_client = <MagicMock name='get_workspace_client()' spec='WorkspaceClient' id='140250912871184'>
@patch("databricks_cdk.resources.service_principals.service_principal.get_workspace_client")
def test_delete_service_principal(patched_get_workspace_client, workspace_client):
patched_get_workspace_client.return_value = workspace_client
mock_properties = ServicePrincipalProperties(
workspace_url="https://test.cloud.databricks.com",
service_principal=ServicePrincipal(
active=True,
display_name="mock_name",
id="some_id",
),
)
> response = delete_service_principal(mock_properties, "some_id")
tests/resources/service_principals/test_service_principal.py:222:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/databricks_cdk/resources/service_principals/service_principal.py:104: in delete_service_principal
workspace_client.service_principals.delete(id=physical_resource_id)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MagicMock name='get_workspace_client()' spec='WorkspaceClient' id='140250912871184'>
name = 'service_principals'
def __getattr__(self, name):
if name in {'_mock_methods', '_mock_unsafe'}:
raise AttributeError(name)
elif self._mock_methods is not None:
if name not in self._mock_methods or name in _all_magics:
> raise AttributeError("Mock object has no attribute %r" % name)
E AttributeError: Mock object has no attribute 'service_principals'
/opt/hostedtoolcache/Python/3.12.8/x64/lib/python3.12/unittest/mock.py:660: AttributeError