def _send_email(form_data, template): # The form_data param should be an instance of form.cleaned_data message_body = render_to_string(template, form_data) try: send_mail( form_data['subject'], message_body, form_data['sender'], get_admin_email_addresses() ) except Exception as e: print e
def test_get_admin_email_addresses_returns_email_addresses(self): emails = get_admin_email_addresses() self.assertIn('*****@*****.**', enumerate(emails).next()) self.assertIn('*****@*****.**', enumerate(emails).next())
def test_get_admin_email_addresses_returns_correct_number_of_email_addresses(self): self.assertEquals(2, len(list(get_admin_email_addresses())))