"""Test for notify_success task.""" from unittest.mock import MagicMock, patch from tasks.accounting_period_calculate_vat.notify_success import \ notify_success_task @patch('tasks.accounting_period_calculate_vat.notify_success.ows' '.get_abacus_states') @patch('tasks.accounting_period_calculate_vat.notify_success.ows' '.get_accounting_period_details') @patch('lib.utils.aws.file_exists') @patch('tasks.accounting_period_calculate_vat.notify_success.helpers' '.set_abacus_action_to_status') def test_notify_success_task( mock_set_status: MagicMock, mock_aws_file_exists: MagicMock, mock_ows_get_accounting_period_details: MagicMock, mock_ows_get_abacus_states: MagicMock, mock_accounting_period_calc_vat_dag_run, mock_ows_requests, ) -> None: """Test updating accounting period actions to COMPLETE 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'] mock_aws_file_exists.return_value = False notify_success_task(mock_accounting_period_calc_vat_dag_run) assert mock_set_status.call_count == 3 assert mock_set_status.call_args_list[0][0] == (1, 'complete') assert mock_set_status.call_args_list[1][0] == (2, 'complete') assert mock_set_status.call_args_list[2][0] == (3, 'complete') mock_ows_get_accounting_period_details.assert_called_once_with(2) mock_ows_get_abacus_states.assert_called_once_with( parent_table_name='accounting_period', parent_table_id=2, )