"""Test for snapshot_account_tax_info task.""" import json from unittest.mock import MagicMock, patch from tasks.accounting_period_calculate_vat.snapshot_account_tax_info import \ snapshot_account_tax_info_task @patch('lib.utils.aws.location') @patch('lib.utils.aws.write_file') @patch('tasks.accounting_period_calculate_vat.snapshot_account_tax_info.ows' '.get_account_tax_info_snapshot') @patch('tasks.accounting_period_calculate_vat.snapshot_account_tax_info.ows' '.get_accounting_period_details') def test_snapshot_account_tax_info_task( mock_ows_get_accounting_period_details: MagicMock, mock_ows_get_account_tax_info_snapshot: MagicMock, mock_aws_write_file: MagicMock, mock_aws_location: MagicMock, mock_accounting_period_calc_vat_dag_run, mock_ows_requests ): """Test snapshotting tax info to vat's s3 subdir.""" mock_ows_get_accounting_period_details.return_value =\ mock_ows_requests['mock_accounting_period'] mock_ows_get_account_tax_info_snapshot.return_value =\ json.dumps(mock_ows_requests['mock_account_tax_info']).encode('utf-8') mock_aws_location.return_value = MagicMock( url='account_tax_info.csv' ) snapshot_account_tax_info_task(mock_accounting_period_calc_vat_dag_run) mock_aws_write_file.assert_called_once_with( 'account_tax_info.csv', json.dumps(mock_ows_requests['mock_account_tax_info']).encode('utf-8') ) mock_ows_get_accounting_period_details.assert_called_once_with(2) mock_ows_get_account_tax_info_snapshot.assert_called_once()