"""Test for create_vat_exempt_report task.""" from unittest.mock import MagicMock, patch from lib.config import S3_SALES_BUCKET_NAME as S3_BUCKET from tasks.accounting_period_calculate_vat.create_vat_exempt_report import \ create_vat_exempt_report_task @patch('tasks.accounting_period_calculate_vat.create_vat_exempt_report' '.ows.get_accounting_run_vat_by_category') @patch('tasks.accounting_period_calculate_vat.create_vat_exempt_report' '.ows.get_accounting_period_details') def test_create_vat_exempt_report_task( mock_ows_get_accounting_period_details: MagicMock, mock_ows_get_accounting_run_vat_by_category: MagicMock, mock_accounting_period_calc_vat_dag_run, mock_ows_requests, ): """Test creating vat exempt report on s3.""" mock_ows_get_accounting_period_details.return_value =\ mock_ows_requests['mock_accounting_period'] mock_ows_get_accounting_run_vat_by_category.return_value =\ mock_ows_requests['mock_ledger_run_vat_exempt'] with patch('pandas.DataFrame.to_csv') as to_csv_mock: create_vat_exempt_report_task(mock_accounting_period_calc_vat_dag_run) to_csv_mock.assert_called_with( f's3://{S3_BUCKET}/2-mock-period-2/vat/reports/vat_exempt.tsv', index=False, sep='\t' ) mock_ows_get_accounting_period_details.assert_called_once_with(2) mock_ows_get_accounting_run_vat_by_category.assert_called_once_with(2, 'vat_exempt')