Skip to content

Add service principal resource #1836

Add service principal resource

Add service principal resource #1836

GitHub Actions / JUnit Test Report failed Dec 16, 2024 in 0s

102 tests run, 0 skipped, 7 failed.

Annotations

Check failure on line 80 in aws-lambda/tests/resources/service_principals/test_service_principal.py

See this annotation in the file changed.

@github-actions 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='140259756477312'>
patched_create_service_principal = <MagicMock name='create_service_principal' id='140259756770304'>
patched_update_service_principal = <MagicMock name='update_service_principal' id='140259756461456'>
patched_get_workspace_client = <MagicMock name='get_workspace_client' id='140259756552784'>
workspace_client = <MagicMock name='get_workspace_client()' spec='WorkspaceClient' id='140259756563904'>

    @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='140259756563904'>
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.8.18/x64/lib/python3.8/unittest/mock.py:637: AttributeError

Check failure on line 116 in aws-lambda/tests/resources/service_principals/test_service_principal.py

See this annotation in the file changed.

@github-actions 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='140259756127280'>

    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='140259756127280'>
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.8.18/x64/lib/python3.8/unittest/mock.py:637: AttributeError

Check failure on line 124 in aws-lambda/tests/resources/service_principals/test_service_principal.py

See this annotation in the file changed.

@github-actions 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='140259755866864'>

    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='140259755866864'>
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.8.18/x64/lib/python3.8/unittest/mock.py:637: AttributeError

Check failure on line 138 in aws-lambda/tests/resources/service_principals/test_service_principal.py

See this annotation in the file changed.

@github-actions 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='140259756038992'>

    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='140259756038992'>
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.8.18/x64/lib/python3.8/unittest/mock.py:637: AttributeError

Check failure on line 168 in aws-lambda/tests/resources/service_principals/test_service_principal.py

See this annotation in the file changed.

@github-actions 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='140259756926048'>

    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='140259756926048'>
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.8.18/x64/lib/python3.8/unittest/mock.py:637: AttributeError

Check failure on line 188 in aws-lambda/tests/resources/service_principals/test_service_principal.py

See this annotation in the file changed.

@github-actions 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='140259756515280'>

    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='140259756515280'>
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.8.18/x64/lib/python3.8/unittest/mock.py:637: AttributeError

Check failure on line 222 in aws-lambda/tests/resources/service_principals/test_service_principal.py

See this annotation in the file changed.

@github-actions 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='140259755926048'>
workspace_client = <MagicMock name='get_workspace_client()' spec='WorkspaceClient' id='140259755927680'>

    @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='140259755927680'>
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.8.18/x64/lib/python3.8/unittest/mock.py:637: AttributeError