"""Test notify_failure task.""" from unittest.mock import patch from lib import constants from tasks.adjustment_file_upload.notify_failure import notify_failure_task @patch('tasks.adjustment_file_upload.notify_failure.helpers') @patch('tasks.adjustment_file_upload.notify_failure.ows') def test_notify_failure_task( mock_ows, mock_helpers, mock_adjustment_file_upload_dag_run ): """Test updating 'adjustment_file_upload' abacus_state record to 'error'.""" statement_period_adjustment_file_id = 1 mock_action = { 'abacus_state_id': 1, 'action_name': constants.STATEMENT_PERIOD_ADJUSTMENT_FILE_ACTIONS.UPLOAD_FILE, 'action_status': constants.ABACUS_STATE_STATUSES.RUNNING } mock_helpers.get_event_from_params.return_value.target_id = \ statement_period_adjustment_file_id mock_helpers.get_abacus_state.return_value = mock_action mock_ows.update_abacus_state.return_value = True notify_failure_task(mock_adjustment_file_upload_dag_run) mock_helpers.get_event_from_params.assert_called_once_with( mock_adjustment_file_upload_dag_run ) mock_helpers.get_abacus_state.assert_called_once_with( constants.STATEMENT_PERIOD_ADJUSTMENT_FILE_ACTIONS.UPLOAD_FILE, statement_period_adjustment_file_id ) mock_ows.update_abacus_state.assert_called_once_with( mock_action.get('abacus_state_id'), body={ 'action_status': constants.ABACUS_STATE_STATUSES.ERROR } )