"""Test email report logic.""" from unittest.mock import patch from royalties.email_report import TaxReportEmail def test_tax_report_email_create(): """Test creating a TaxReportEmail Instance.""" mock_tax_report_email = TaxReportEmail( 'file_path', 'a@b.c', ['d@e.f'], 'month', '250' ) actual = mock_tax_report_email.get_report_name() assert actual == 'Tax Withholding: interval[month]+periods[250]' @patch('royalties.email_report.Path') @patch('royalties.email_report.boto3') def test_tax_report_format(mock_boto, mock_path): """Test building and triggering an email.""" mock_path.return_value.read_bytes.return_value = b'ok' mock_tax_report_email = TaxReportEmail( 'file_path', 'a@b.c', ['d@e.f'], 'month', '250' ) mock_tax_report_email.build_email() mock_tax_report_email.trigger_email() call_args = mock_boto.client.return_value.send_raw_email.call_args assert call_args[1].get('Source') == 'a@b.c' assert call_args[1].get('Destinations') == ['d@e.f']