@@ -257,3 +257,58 @@ def test_workflow_task_container_builds_dependency_graph_with_known_egg_library(
257257 assert len (problems ) == 0
258258 assert graph .path_lookup .resolve (Path ("thingy" )) is not None
259259 ws .workspace .download .assert_called_once_with (egg_file .as_posix (), format = ExportFormat .AUTO )
260+
261+
262+ def test_workflow_task_container_builds_dependency_graph_with_missing_distribution_in_python_wheel_task (
263+ mock_path_lookup ,
264+ graph ,
265+ ):
266+ ws = create_autospec (WorkspaceClient )
267+ python_wheel_task = jobs .PythonWheelTask (package_name = "databricks_labs_ucx" , entry_point = "runtime" )
268+ task = jobs .Task (task_key = "test" , python_wheel_task = python_wheel_task )
269+
270+ workflow_task_container = WorkflowTaskContainer (ws , task )
271+ problems = workflow_task_container .build_dependency_graph (graph )
272+
273+ assert len (problems ) == 1
274+ assert problems [0 ].code == "distribution-not-found"
275+ assert problems [0 ].message == "Could not find distribution for databricks_labs_ucx"
276+ ws .assert_not_called ()
277+
278+
279+ def test_workflow_task_container_builds_dependency_graph_with_missing_entrypoint_in_python_wheel_task (graph ):
280+ ws = create_autospec (WorkspaceClient )
281+
282+ whl_file = Path (__file__ ).parent / "samples/distribution/dist/thingy-0.0.1-py2.py3-none-any.whl"
283+ with whl_file .open ("rb" ) as f :
284+ ws .workspace .download .return_value = io .BytesIO (f .read ())
285+
286+ python_wheel_task = jobs .PythonWheelTask (package_name = "thingy" , entry_point = "non_existing_entrypoint" )
287+ libraries = [compute .Library (whl = whl_file .as_posix ())]
288+ task = jobs .Task (task_key = "test" , libraries = libraries , python_wheel_task = python_wheel_task )
289+
290+ workflow_task_container = WorkflowTaskContainer (ws , task )
291+ problems = workflow_task_container .build_dependency_graph (graph )
292+
293+ assert len (problems ) == 1
294+ assert problems [0 ].code == "distribution-entry-point-not-found"
295+ assert problems [0 ].message == "Could not find distribution entry point for thingy.non_existing_entrypoint"
296+ ws .workspace .download .assert_called_once_with (whl_file .as_posix (), format = ExportFormat .AUTO )
297+
298+
299+ def test_workflow_task_container_builds_dependency_graph_for_python_wheel_task (graph ):
300+ ws = create_autospec (WorkspaceClient )
301+
302+ whl_file = Path (__file__ ).parent / "samples/distribution/dist/thingy-0.0.1-py2.py3-none-any.whl"
303+ with whl_file .open ("rb" ) as f :
304+ ws .workspace .download .return_value = io .BytesIO (f .read ())
305+
306+ python_wheel_task = jobs .PythonWheelTask (package_name = "thingy" , entry_point = "runtime" )
307+ libraries = [compute .Library (whl = whl_file .as_posix ())]
308+ task = jobs .Task (task_key = "test" , libraries = libraries , python_wheel_task = python_wheel_task )
309+
310+ workflow_task_container = WorkflowTaskContainer (ws , task )
311+ problems = workflow_task_container .build_dependency_graph (graph )
312+
313+ assert len (problems ) == 0
314+ ws .workspace .download .assert_called_once_with (whl_file .as_posix (), format = ExportFormat .AUTO )
0 commit comments