Skip to content

Commit cb5e6ef

Browse files
authored
More tests (#2812)
## Changes Add tests to reproduce #2810 ### Linked issues Resolves #2810 ### Functionality None ### Tests - [x] added unit tests - [x] added integration tests --------- Co-authored-by: Eric Vergnaud <eric.vergnaud@databricks.com>
1 parent dc1d1db commit cb5e6ef

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

tests/integration/assessment/test_workflows.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ def test_running_real_assessment_job(
1111
make_cluster_policy,
1212
make_cluster_policy_permissions,
1313
make_dashboard,
14+
sql_backend,
15+
inventory_schema,
1416
) -> None:
1517
ws_group, _ = installation_ctx.make_ucx_group()
1618
# TODO: Move `make_cluster_policy` and `make_cluster_policy_permissions` to context like other `make_` methods
@@ -43,7 +45,9 @@ def test_running_real_assessment_job(
4345
after = installation_ctx.generic_permissions_support.load_as_dict("cluster-policies", cluster_policy.policy_id)
4446
assert after[ws_group.display_name] == PermissionLevel.CAN_USE
4547

46-
tables = set(table.name for table in installation_ctx.tables_crawler.snapshot())
4748
expected_tables = {managed_table.name, external_table.name, tmp_table.name, view.name, non_delta.name}
48-
assert len(tables) == len(expected_tables)
49-
assert set(tables) == expected_tables
49+
assert set(table.name for table in installation_ctx.tables_crawler.snapshot()) == expected_tables
50+
51+
query = f"SELECT * FROM {inventory_schema}.workflow_problems"
52+
for row in sql_backend.fetch(query):
53+
assert row['path'] != 'UNKNOWN'

tests/unit/source_code/test_jobs.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
DependencyGraph,
2424
DependencyResolver,
2525
)
26-
from databricks.labs.ucx.source_code.jobs import JobProblem, WorkflowLinter, WorkflowTaskContainer
26+
from databricks.labs.ucx.source_code.jobs import JobProblem, WorkflowLinter, WorkflowTaskContainer, LintingWalker
2727
from databricks.labs.ucx.source_code.notebooks.loaders import NotebookResolver, NotebookLoader
2828
from databricks.labs.ucx.source_code.used_table import UsedTablesCrawler
2929

@@ -521,3 +521,15 @@ def test_xxx(graph):
521521
assert workflow_task_container.spark_conf == {"spark.databricks.cluster.profile": "singleNode"}
522522

523523
ws.assert_not_called()
524+
525+
526+
def test_linting_walker_populates_paths(dependency_resolver, mock_path_lookup, migration_index):
527+
path = mock_path_lookup.resolve(Path("functional/values_across_cells.py"))
528+
root = Dependency(NotebookLoader(), path)
529+
xgraph = DependencyGraph(root, None, dependency_resolver, mock_path_lookup, CurrentSessionState())
530+
walker = LintingWalker(xgraph, set(), mock_path_lookup, "key", CurrentSessionState(), migration_index)
531+
advices = 0
532+
for advice in walker:
533+
advices += 1
534+
assert "UNKNOWN" not in advice.path.as_posix()
535+
assert advices

0 commit comments

Comments
 (0)