def test_arguments_get_passsed_to_get_email_message(self, mocked_backend):
        get_templated_mail(*self.TEST_ARGS, **self.TEST_KWARGS)

        mocked_backend.assert_called_with(template_prefix='prefix',
                                          template_suffix='suffix')

        get_email_message = mocked_backend.return_value.get_email_message

        kwargs = dict(self.TEST_KWARGS)
        del kwargs['template_dir']
        del kwargs['file_extension']
        get_email_message.assert_called_with(*self.TEST_ARGS, **kwargs)
    def test_arguments_get_email_message_fallback(self, mocked_backend):
        kwargs = dict(self.TEST_KWARGS)
        del kwargs['template_prefix']
        del kwargs['template_suffix']

        get_templated_mail(*self.TEST_ARGS, **kwargs)

        mocked_backend.assert_called_with(template_prefix=kwargs['template_dir'],
                                          template_suffix=kwargs['file_extension'])

        get_email_message = mocked_backend.return_value.get_email_message

        kwargs['template_prefix'] = kwargs.pop('template_dir')
        kwargs['template_suffix'] = kwargs.pop('file_extension')
        get_email_message.assert_called_with(*self.TEST_ARGS, **kwargs)
Пример #3
0
def multi_templated_email(templateName, to_emails, from_email, context):
    """
    send separate emails to multiple recipients using a template
    """
    for to in to_emails:
      email = get_templated_mail(templateName, context=context, from_email=from_email, to=[to])
      email.send()
Пример #4
0
 def email_invitees(round_url, round_donations, round_expiration, round_invitees):
   """
   email sent by round creator to invite other people to the round by email
   """
   email_from = '[email protected]'
   invitees_list = round_invitees.split(',')
   time_left = round_expiration.replace(tzinfo=None) - datetime.now().replace(tzinfo=None)
   round_donation_str = "Fake Person, Another Fake Person" #TODO: r.name for r in round_donations
   
   for invitee in invitees_list:
       email = get_templated_mail('invite', context={}, from_email=email_from, to=[invitee])
       email.send()
 def test_called_get_email_message_from_vanilla_backend(self, mocked_backend):
     get_templated_mail(*self.TEST_ARGS)
     mocked_backend.return_value.get_email_message.assert_called_once()
 def test_get_templated_mail_returns_response_of_get_email_message(
         self, mocked_backend):
     ret = get_templated_mail(*self.TEST_ARGS)
     self.assertTrue(
         ret is mocked_backend.return_value.get_email_message.return_value)