@@ -54,3 +54,25 @@ def test_archive_workflow(tmpdir, mocker, test_function, expected_state):
54
54
mock_update_wf_status .assert_called_once_with ("wf_id_test" , expected_state )
55
55
mock_remove_wf_dir .assert_called_once_with ("wf_id_test" )
56
56
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