From 1fa15f5e1355cd502bf4b54bd220ca249083e75a Mon Sep 17 00:00:00 2001 From: Cor Zuurmond Date: Tue, 8 Oct 2024 14:34:41 +0200 Subject: [PATCH] Test valid migration progress prerequisites --- tests/unit/progress/test_workflows.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/unit/progress/test_workflows.py b/tests/unit/progress/test_workflows.py index acca28ff06..2cfff7aad9 100644 --- a/tests/unit/progress/test_workflows.py +++ b/tests/unit/progress/test_workflows.py @@ -3,6 +3,8 @@ import pytest from databricks.sdk import WorkspaceClient from databricks.sdk.errors import PermissionDenied +from databricks.sdk.service.catalog import CatalogInfo, MetastoreAssignment +from databricks.sdk.service.jobs import BaseRun, RunResultState, RunState from databricks.labs.ucx.assessment.clusters import ClustersCrawler, PoliciesCrawler from databricks.labs.ucx.assessment.jobs import JobsCrawler @@ -39,6 +41,20 @@ def test_migration_progress_runtime_refresh(run_workflow, task, crawler, crawler mock_crawler.snapshot.assert_called_once_with(force_refresh=True) +def test_migration_progress_with_valid_prerequisites(run_workflow) -> None: + ws = create_autospec(WorkspaceClient) + ws.metastores.current.return_value = MetastoreAssignment(metastore_id="test", workspace_id=123456789) + ws.catalogs.get.return_value = CatalogInfo() + ws.jobs.list_runs.return_value = [BaseRun(state=RunState(result_state=RunResultState.SUCCESS))] + task = MigrationProgress.verify_prerequisites + try: + run_workflow(task, workspace_client=ws) + except RuntimeError as e: + assert False, f"{task} raise error: {e}" + else: + assert True, "Valid prerequisites found" + + def test_migration_progress_raises_runtime_error_if_metastore_not_attached_to_workflow(run_workflow) -> None: ws = create_autospec(WorkspaceClient) ws.metastores.current.return_value = None