Skip to content

Commit 55553f1

Browse files
committed
Regression test task failure archiving
1 parent db33f9a commit 55553f1

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

beeflow/tests/test_wf_update.py

+22
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,25 @@ def test_archive_workflow(tmpdir, mocker, test_function, expected_state):
5454
mock_update_wf_status.assert_called_once_with("wf_id_test", expected_state)
5555
mock_remove_wf_dir.assert_called_once_with("wf_id_test")
5656
mock_log.assert_called_once_with("Removing Workflow Directory")
57+
58+
59+
@pytest.mark.parametrize(
60+
"wf_state, tries_to_archive", [("Archived", False), ("Running", True)]
61+
)
62+
def test_failed_task_wf_archive(mocker, wf_state, tries_to_archive):
63+
"""Failed task archives workflow if not archived."""
64+
task = mocker.MagicMock()
65+
db = mocker.MagicMock()
66+
db.workflows.get_workflow_state.return_value = wf_state
67+
state_update = mocker.MagicMock()
68+
state_update.job_state = "FAILED"
69+
wfi = mocker.MagicMock()
70+
wfi.workflow_id = "123456"
71+
mock_archive_fail_workflow = mocker.patch(
72+
"beeflow.wf_manager.resources.wf_update.archive_fail_workflow"
73+
)
74+
mock_log_info = mocker.patch("logging.Logger.info")
75+
wfu = wf_update.WFUpdate()
76+
wfu.handle_state_change(state_update, task, wfi, db)
77+
assert tries_to_archive == len(mock_archive_fail_workflow.mock_calls)
78+
assert tries_to_archive == len(mock_log_info.mock_calls)

0 commit comments

Comments
 (0)