def test_send_email_sendgrid_correct_email(self, mock_post): with tempfile.NamedTemporaryFile(mode='wt', suffix='.txt') as f: f.write('this is some test data') f.flush() filename = os.path.basename(f.name) expected_mail_data = dict( self.expected_mail_data, attachments=[{ 'content': 'dGhpcyBpcyBzb21lIHRlc3QgZGF0YQ==', 'content_id': f'<{filename}>', 'disposition': 'attachment', 'filename': filename, 'type': 'text/plain', }], ) send_email( self.recepients, self.subject, self.html_content, cc=self.carbon_copy, bcc=self.bcc, files=[f.name], ) mock_post.assert_called_once_with(expected_mail_data, "sendgrid_default")
def test_send_email_sendgrid_sender(self, mock_post): send_email(self.recepients, self.subject, self.html_content, cc=self.carbon_copy, bcc=self.bcc, from_email='*****@*****.**', from_name='Foo Bar') mock_post.assert_called_once_with(self.expected_mail_data_sender)
def test_send_email_sendgrid_correct_email_extras(self, mock_post): send_email( self.recepients, self.subject, self.html_content, cc=self.carbon_copy, bcc=self.bcc, personalization_custom_args=self.personalization_custom_args, categories=self.categories) mock_post.assert_called_once_with(self.expected_mail_data_extras)