"""Test notify_started task.""" from unittest.mock import patch from lib import constants from tasks.adjustment_file_upload.notify_started import notify_started_task @patch('tasks.adjustment_file_upload.notify_started.helpers') @patch('tasks.adjustment_file_upload.notify_started.ows') def test_notify_started_task( mock_ows, mock_helpers, mock_adjustment_file_upload_dag_run ): """Test updating 'adjustment_file_upload' abacus_state record to 'running'.""" 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.INIT } 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_started_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.RUNNING } )