def test_send_email_sendgrid_correct_email(self, mock_post, mock_get):
        def get_return(var):
            return {'SENDGRID_MAIL_FROM': '*****@*****.**'}.get(var)

        mock_get.side_effect = get_return
        send_email(self.to, self.subject, self.html_content, cc=self.cc, bcc=self.bcc)
        mock_post.assert_called_with(self.expected_mail_data)
Esempio n. 2
0
    def test_send_email_sendgrid_correct_email(self, mock_post, mock_get):
        def get_return(var):
            return {'SENDGRID_MAIL_FROM': '*****@*****.**'}.get(var)

        mock_get.side_effect = get_return
        send_email(self.to, self.subject, self.html_content, cc=self.cc, bcc=self.bcc)
        mock_post.assert_called_with(self.expected_mail_data)
 def test_send_email_sendgrid_correct_email(self, mock_post, mock_get):
     mock_get.return_value = '*****@*****.**'
     send_email(self.to,
                self.subject,
                self.html_content,
                cc=self.cc,
                bcc=self.bcc)
     mock_post.assert_called_with(self.expected_mail_data)
Esempio n. 4
0
 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)
Esempio n. 5
0
 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)
Esempio n. 6
0
    def test_send_email_sendgrid_correct_email_extras(self, mock_post, mock_get):
        def get_return(var):
            return {'SENDGRID_MAIL_FROM': '*****@*****.**',
                    'SENDGRID_MAIL_SENDER': 'Foo'}.get(var)

        mock_get.side_effect = get_return
        send_email(self.to, self.subject, self.html_content, cc=self.cc, bcc=self.bcc,
                   personalization_custom_args=self.personalization_custom_args,
                   categories=self.categories)
        mock_post.assert_called_with(self.expected_mail_data_extras)
    def test_send_email_sendgrid_correct_email_extras(self, mock_post, mock_get):
        def get_return(var):
            return {'SENDGRID_MAIL_FROM': '*****@*****.**',
                    'SENDGRID_MAIL_SENDER': 'Foo'}.get(var)

        mock_get.side_effect = get_return
        send_email(self.to, self.subject, self.html_content, cc=self.cc, bcc=self.bcc,
                   personalization_custom_args=self.personalization_custom_args,
                   categories=self.categories)
        mock_post.assert_called_with(self.expected_mail_data_extras)
Esempio n. 8
0
    def test_send_email_sendgrid_sender(self, mock_post, mock_get):

        mock_get.return_value = None
        send_email(self.to,
                   self.subject,
                   self.html_content,
                   cc=self.cc,
                   bcc=self.bcc,
                   from_email='*****@*****.**',
                   from_name='Foo Bar')
        mock_post.assert_called_with(self.expected_mail_data_sender)
Esempio n. 9
0
 def test_send_email_sendgrid_correct_email_custom_args(
         self, mock_post, mock_get):
     mock_get.return_value = '*****@*****.**'
     send_email(
         self.to,
         self.subject,
         self.html_content,
         cc=self.cc,
         bcc=self.bcc,
         personalization_custom_args=self.personalization_custom_args)
     mock_post.assert_called_with(self.expected_mail_data_custom_args)
Esempio n. 10
0
    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': '<{0}>'.format(filename),
                    'disposition': 'attachment',
                    'filename': filename,
                    'type': 'text/plain',
                }],
            )

            send_email(self.to,
                       self.subject,
                       self.html_content,
                       cc=self.cc,
                       bcc=self.bcc,
                       files=[f.name])
            mock_post.assert_called_with(expected_mail_data)
Esempio n. 11
0
    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': '<{0}>'.format(filename),
                    'disposition': 'attachment',
                    'filename': filename,
                    'type': 'text/plain',
                }],
            )

            send_email(self.to,
                       self.subject,
                       self.html_content,
                       cc=self.cc,
                       bcc=self.bcc,
                       files=[f.name])
            mock_post.assert_called_with(expected_mail_data)
Esempio n. 12
0
 def test_send_email_sendgrid_correct_email_custom_args(self, mock_post, mock_get):
     mock_get.return_value = '*****@*****.**'
     send_email(self.to, self.subject, self.html_content, cc=self.cc, bcc=self.bcc,
                personalization_custom_args=self.personalization_custom_args)
     mock_post.assert_called_with(self.expected_mail_data_custom_args)
Esempio n. 13
0
 def test_send_email_sendgrid_correct_email(self, mock_post, mock_get):
     mock_get.return_value = '*****@*****.**'
     send_email(self.to, self.subject, self.html_content, cc=self.cc, bcc=self.bcc)
     mock_post.assert_called_with(self.expected_mail_data)
Esempio n. 14
0
 def test_send_email_sendgrid_sender(self, mock_post):
     send_email(self.to, self.subject, self.html_content, cc=self.cc, bcc=self.bcc,
                from_email='*****@*****.**', from_name='Foo Bar')
     mock_post.assert_called_with(self.expected_mail_data_sender)
Esempio n. 15
0
 def test_send_email_sendgrid_correct_email_extras(self, mock_post):
     send_email(self.to, self.subject, self.html_content, cc=self.cc, bcc=self.bcc,
                personalization_custom_args=self.personalization_custom_args,
                categories=self.categories)
     mock_post.assert_called_with(self.expected_mail_data_extras)