コード例 #1
0
 def test_subject_can_be_a_promise(self):
     """Subject can be a promise object (lazy translation)"""
     builder = EmailBuilder(
         subject=translation.ugettext_lazy("test subject"))
     kwargs = builder.get_message_kwargs()
     assert not isinstance(kwargs['subject'], functional.Promise)
     assert kwargs['subject'] == "test subject"
コード例 #2
0
 def test_send_shortcut(self):
     EmailBuilder.send(to=['*****@*****.**'], subject="Test subject",
         body="Test body")
     assert len(mail.outbox) == 1
     assert mail.outbox[0].to == ['*****@*****.**']
     assert mail.outbox[0].subject == "Test subject"
     assert mail.outbox[0].body == "Test body"
コード例 #3
0
 def test_send_shortcut(self):
     EmailBuilder.send(to=['*****@*****.**'],
                       subject="Test subject",
                       body="Test body")
     assert len(mail.outbox) == 1
     assert mail.outbox[0].to == ['*****@*****.**']
     assert mail.outbox[0].subject == "Test subject"
     assert mail.outbox[0].body == "Test body"
コード例 #4
0
 def test_default_kwargs(self):
     """Check default message keyword arguments"""
     builder = EmailBuilder()
     kwargs = builder.get_message_kwargs()
     expected = {'to': None, 'cc': None, 'bcc': None, 'subject': '',
                 'connection': None, 'from_email': None, 'headers': None,
                 'attachments': None, 'body': ''}
     assert kwargs == expected
コード例 #5
0
    def test_message_building(self):
        """
        Checks if e-mail class can be customized using mail_class and if it
        will receive all arguments it should
        """
        class Dummy(object):
            def __init__(self, **kwargs):
                self.kwargs = kwargs

        kwargs = copy.deepcopy(self.default_kwargs)
        builder = EmailBuilder(mail_class=Dummy, **kwargs)
        msg = builder.build()
        assert isinstance(msg, Dummy)
        assert msg.kwargs == kwargs
コード例 #6
0
    def test_message_building(self):
        """
        Checks if e-mail class can be customized using mail_class and if it
        will receive all arguments it should
        """
        class Dummy(object):
            def __init__(self, **kwargs):
                self.kwargs = kwargs

        kwargs = copy.deepcopy(self.default_kwargs)
        builder = EmailBuilder(mail_class=Dummy, **kwargs)
        msg = builder.build()
        assert isinstance(msg, Dummy)
        assert msg.kwargs == kwargs
コード例 #7
0
 def test_default_kwargs(self):
     """Check default message keyword arguments"""
     builder = EmailBuilder()
     kwargs = builder.get_message_kwargs()
     expected = {
         'to': None,
         'cc': None,
         'bcc': None,
         'subject': '',
         'connection': None,
         'from_email': None,
         'headers': None,
         'attachments': None,
         'body': ''
     }
     assert kwargs == expected
コード例 #8
0
 def test_invalid_keyword_argument(self):
     with pytest.raises(TypeError):
         EmailBuilder(invalid_keyword_argument=1)
コード例 #9
0
 def test_get_message_kwargs_method(self):
     """Checks if all kwargs can be changed using attributes"""
     kwargs = copy.deepcopy(self.default_kwargs)
     builder = EmailBuilder(**kwargs)
     assert builder.get_message_kwargs() == kwargs
コード例 #10
0
 def test_subject_can_be_a_promise(self):
     """Subject can be a promise object (lazy translation)"""
     builder = EmailBuilder(subject=translation.ugettext_lazy("test subject"))
     kwargs = builder.get_message_kwargs()
     assert not isinstance(kwargs['subject'], functional.Promise)
     assert kwargs['subject'] == "test subject"
コード例 #11
0
 def test_get_message_kwargs_method(self):
     """Checks if all kwargs can be changed using attributes"""
     kwargs = copy.deepcopy(self.default_kwargs)
     builder = EmailBuilder(**kwargs)
     assert builder.get_message_kwargs() == kwargs