Skip to content

Commit

Permalink
add unit tests for for_cli in azure_credentials.py
Browse files Browse the repository at this point in the history
  • Loading branch information
qziyuan committed Feb 21, 2024
1 parent b365488 commit a2a51cf
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/unit/migration/test_azure_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,34 @@
)
from databricks.sdk.service.workspace import GetSecretResponse

from databricks.labs.blueprint.tui import MockPrompts
from databricks.labs.ucx.assessment.azure import StoragePermissionMapping, \
AzureServicePrincipalCrawler, AzureServicePrincipalInfo
from databricks.labs.ucx.migration.azure_credentials import (
AzureServicePrincipalMigration, ServicePrincipalMigrationInfo,
)
from tests.unit.framework.mocks import MockBackend
from tests.unit.test_cli import ws


def test_for_cli_not_azure():
w = create_autospec(WorkspaceClient)
w.config.is_azure.return_value = False
assert AzureServicePrincipalMigration.for_cli(w, MagicMock()) is None


def test_for_cli_not_prompts():
w = create_autospec(WorkspaceClient)
w.config.is_azure.return_value = True
prompts = MockPrompts({"Have you reviewed the azure_storage_account_info.csv *": "No"})
assert AzureServicePrincipalMigration.for_cli(w, prompts) is None


def test_for_cli(ws):
ws.config.is_azure.return_value = True
prompts = MockPrompts({"Have you reviewed the azure_storage_account_info.csv *": "Yes"})

assert isinstance(AzureServicePrincipalMigration.for_cli(ws, prompts), AzureServicePrincipalMigration)


def test_list_storage_credentials():
Expand Down

0 comments on commit a2a51cf

Please sign in to comment.