Skip to content

Commit 027e55e

Browse files
committed
Fix unit tests and cli command
1 parent ef36217 commit 027e55e

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

src/databricks/labs/ucx/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ def ensure_assessment_run(
239239
)
240240
else:
241241
logger.info(f"Starting assessment workflow in workspace: {workspace_id}")
242+
deployed_workflows.run_workflow("assessment", skip_job_wait=run_as_collection)
242243
# If running for a collection, don't wait for each assessment job to finish as that will take a long time.
243244

244245

tests/unit/install/test_install.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,9 @@ def test_writeable_dbfs(ws, tmp_path, mock_installation) -> None:
180180

181181

182182
def test_run_workflow_creates_proper_failure(ws, mocker, mock_installation_with_jobs):
183-
def run_now(job_id, _job_parameters: dict[str, Any] | None = None):
183+
def run_now(job_id, job_parameters: dict[str, Any] | None = None):
184184
assert job_id == 123
185+
assert job_parameters is None
185186

186187
def result():
187188
raise OperationFailed(...)
@@ -215,8 +216,9 @@ def result():
215216

216217

217218
def test_run_workflow_run_id_not_found(ws, mocker, mock_installation_with_jobs):
218-
def run_now(job_id, _job_parameters: dict[str, Any] | None = None):
219+
def run_now(job_id, job_parameters: dict[str, Any] | None = None):
219220
assert job_id == 123
221+
assert job_parameters is None
220222

221223
def result():
222224
raise OperationFailed(...)
@@ -246,8 +248,9 @@ def result():
246248

247249

248250
def test_run_workflow_creates_failure_from_mapping(ws, mocker, mock_installation, mock_installation_with_jobs):
249-
def run_now(job_id, _job_parameters: dict[str, Any] | None = None):
251+
def run_now(job_id, job_parameters: dict[str, Any] | None = None):
250252
assert job_id == 123
253+
assert job_parameters is None
251254

252255
def result():
253256
raise OperationFailed(...)
@@ -281,8 +284,9 @@ def result():
281284

282285

283286
def test_run_workflow_creates_failure_many_error(ws, mocker, mock_installation_with_jobs):
284-
def run_now(job_id, _job_parameters: dict[str, Any] | None = None):
287+
def run_now(job_id, job_parameters: dict[str, Any] | None = None):
285288
assert job_id == 123
289+
assert job_parameters is None
286290

287291
def result():
288292
raise OperationFailed(...)

tests/unit/installer/test_workflows.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def test_run_workflow(mock_installation) -> None:
8787
run_id = workflows.run_workflow("test")
8888

8989
assert run_id == 456
90-
ws.jobs.run_now.assert_called_once_with(123)
90+
ws.jobs.run_now.assert_called_once_with(123, job_parameters=None)
9191
ws.jobs.wait_get_run_job_terminated_or_skipped.assert_called_once_with(run_id=456, timeout=timedelta(minutes=20))
9292

9393

@@ -101,7 +101,7 @@ def test_run_workflow_skip_job_wait(mock_installation) -> None:
101101
run_id = workflows.run_workflow("test", skip_job_wait=True)
102102

103103
assert run_id == 456
104-
ws.jobs.run_now.assert_called_once_with(123)
104+
ws.jobs.run_now.assert_called_once_with(123, job_parameters=None)
105105
ws.jobs.wait_get_run_job_terminated_or_skipped.assert_not_called()
106106

107107

@@ -121,7 +121,7 @@ def test_run_workflow_operation_failed(mock_installation) -> None:
121121
with pytest.raises(NotFound, match="a_table"):
122122
_ = workflows.run_workflow("test")
123123

124-
ws.jobs.run_now.assert_called_once_with(123)
124+
ws.jobs.run_now.assert_called_once_with(123, job_parameters=None)
125125
ws.jobs.wait_get_run_job_terminated_or_skipped.assert_called_once_with(run_id=456, timeout=timedelta(minutes=20))
126126
ws.jobs.get_run.assert_called_once_with(456)
127127
ws.workspace.list.assert_called_once_with("~/mock/logs/test")
@@ -139,6 +139,6 @@ def test_run_workflow_timeout(mock_installation) -> None:
139139
with pytest.raises(TimeoutError):
140140
_ = workflows.run_workflow("test", max_wait=timedelta(minutes=2))
141141

142-
ws.jobs.run_now.assert_called_once_with(123)
142+
ws.jobs.run_now.assert_called_once_with(123, job_parameters=None)
143143
ws.jobs.wait_get_run_job_terminated_or_skipped.assert_called_once_with(run_id=456, timeout=timedelta(minutes=2))
144144
ws.workspace.list.assert_called_once_with("~/mock/logs/test")

tests/unit/test_cli.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ def test_ensure_assessment_run_collection(workspace_clients, acc_client):
406406
ensure_assessment_run(workspace_clients[0], run_as_collection=True, a=acc_client)
407407

408408
for workspace_client in workspace_clients:
409-
workspace_client.jobs.run_now.assert_called_with(123)
409+
workspace_client.jobs.run_now.assert_called_with(123, job_parameters=None)
410410

411411

412412
def test_repair_run(ws):
@@ -1035,7 +1035,7 @@ def test_migrate_tables_calls_migrate_table_job_run_now(
10351035
migrate_tables(workspace_clients[0], MockPrompts({}), run_as_collection=run_as_collection, a=acc_client)
10361036

10371037
for workspace_client in workspace_clients:
1038-
workspace_client.jobs.run_now.assert_called_with(456)
1038+
workspace_client.jobs.run_now.assert_called_with(456, job_parameters=None)
10391039
workspace_client.jobs.wait_get_run_job_terminated_or_skipped.assert_called_once()
10401040

10411041

@@ -1079,7 +1079,7 @@ def test_migrate_tables_calls_external_hiveserde_tables_job_run_now(ws) -> None:
10791079

10801080
migrate_tables(ws, prompts, ctx=ctx)
10811081

1082-
ws.jobs.run_now.assert_called_with(789)
1082+
ws.jobs.run_now.assert_called_with(789, job_parameters=None)
10831083
ws.jobs.wait_get_run_job_terminated_or_skipped.call_count = 2
10841084

10851085

@@ -1114,7 +1114,7 @@ def test_migrate_tables_calls_external_tables_ctas_job_run_now(ws) -> None:
11141114

11151115
migrate_tables(ws, prompts, ctx=ctx)
11161116

1117-
ws.jobs.run_now.assert_called_with(987)
1117+
ws.jobs.run_now.assert_called_with(987, job_parameters=None)
11181118
ws.jobs.wait_get_run_job_terminated_or_skipped.call_count = 2
11191119

11201120

0 commit comments

Comments
 (0)