"""Test for notify_failure task.""" from unittest.mock import patch from tasks.accounting_period_calculate_vat.notify_failure import \ notify_failure_task @patch('tasks.accounting_period_calculate_vat.notify_failure.ows') @patch('tasks.accounting_period_calculate_vat.notify_failure.helpers' '.set_abacus_action_to_status') def test_notify_failure_task( mock_set_status, mock_ows, mock_accounting_period_calc_vat_event, mock_accounting_period_calc_vat_dag_run, mock_ows_requests, ): """Test updating accounting period actions to ERROR status.""" mock_ows.get_accounting_period_details.return_value = \ mock_ows_requests['mock_accounting_period'] mock_ows.get_abacus_states.return_value = \ mock_ows_requests['mock_abacus_states'] notify_failure_task(mock_accounting_period_calc_vat_dag_run) assert mock_set_status.call_count == 1 assert mock_set_status.call_args_list[0][0] == (1, 'error') mock_ows.get_accounting_period_details.assert_called_once_with( mock_accounting_period_calc_vat_event['target_id']) mock_ows.get_abacus_states.assert_called_once_with( parent_table_name='accounting_period', parent_table_id=mock_ows_requests[ 'mock_accounting_period' ]['accounting_period_id'] )