Skip to content
This repository was archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
set return value of list_jobs.get() to empty list to ensure create_jo…
Browse files Browse the repository at this point in the history
…b functionality is correctly tested
  • Loading branch information
Hang1225 committed Apr 11, 2024
1 parent a37d5a3 commit 8b3b920
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/databricks/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ def test_create_workflow_from_notebooks_with_create(
mock_run_api, mock_jobs_api, mock_api, mock_hook, dag
):
mock_jobs_api.return_value.create_job.return_value = {"job_id": 1}
# In unittest, this function returns a MagicMock object by default, which updates an existing workflow instead of creating a new one.
# This causes the create_job assertion to fail. To prevent this, the function's return value should be overridden to an empty list.
mock_jobs_api.return_value.list_jobs.return_value.get.return_value = []

with dag:
task_group = DatabricksWorkflowTaskGroup(
group_id="test_workflow",
Expand Down Expand Up @@ -391,6 +395,8 @@ def test_create_workflow_from_notebooks_with_different_clusters(
mock_run_api, mock_jobs_api, mock_api, mock_hook, dag
):
mock_jobs_api.return_value.create_job.return_value = {"job_id": 1}
mock_jobs_api.return_value.list_jobs.return_value.get.return_value = []

with dag:
task_group = DatabricksWorkflowTaskGroup(
group_id="test_workflow",
Expand Down

0 comments on commit 8b3b920

Please sign in to comment.