-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from deployed/add_default_reply_to_support
Support for default reply_to email
- Loading branch information
Showing
6 changed files
with
32 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1 @@ | ||
# encoding: utf-8 | ||
from test_helpers import * | ||
from test_email import * | ||
from test_template_registry import * | ||
from test_models import * | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
from django.conf import settings | ||
from django.core import mail | ||
from django.test import TestCase | ||
from django.test import TestCase, override_settings | ||
from django.utils.html import escape | ||
from mock import Mock | ||
|
||
|
@@ -16,7 +16,10 @@ | |
|
||
|
||
class CheckEmail(TestCase): | ||
def check_email_was_sent(self, eft, to): | ||
def check_email_was_sent(self, eft, to, reply_to=None): | ||
if reply_to is None: | ||
reply_to = [] | ||
|
||
self.assertTrue(len(mail.outbox) > 0) | ||
msg = mail.outbox[0] | ||
self.assertTrue(settings.DEFAULT_FROM_EMAIL in msg.from_email) | ||
|
@@ -25,6 +28,7 @@ def check_email_was_sent(self, eft, to): | |
self.assertEqual(msg.body, eft.message) | ||
self.assertTrue('Message-Id' in msg.message()) | ||
self.assertEqual(msg.to, to) | ||
self.assertEqual(msg.reply_to, reply_to) | ||
|
||
|
||
class EmailFromTemplateTest(CheckEmail): | ||
|
@@ -34,7 +38,17 @@ def setUp(self): | |
email_logger.warning = Mock() | ||
self.attachment_filepath = os.path.join(os.path.dirname(__file__), 'data', 'example_file.txt') | ||
|
||
@override_settings(DEFAULT_REPLY_TO_EMAIL='[email protected]') | ||
def test_empty_object(self): | ||
eft = EmailFromTemplate(registry_validation=False) | ||
self.assertTrue(isinstance(eft, object)) | ||
eft.render_message() | ||
to = ['[email protected]'] | ||
eft.send_email(to) | ||
self.check_email_was_sent(eft, to, reply_to=['[email protected]']) | ||
|
||
@override_settings(DEFAULT_REPLY_TO_EMAIL=None) | ||
def test_empty_object_with_empty_reply_to(self): | ||
eft = EmailFromTemplate(registry_validation=False) | ||
self.assertTrue(isinstance(eft, object)) | ||
eft.render_message() | ||
|
@@ -84,9 +98,10 @@ def setUp(self): | |
email_logger.debug = Mock() | ||
|
||
def test_support_database_template(self): | ||
eft = EmailFromTemplate(name='support_respond.html', language=self.language, registry_validation=False) | ||
template_name = 'support_respond.html' | ||
eft = EmailFromTemplate(name=template_name, language=self.language, registry_validation=False) | ||
eft.get_object() | ||
email_logger.debug.assert_called_with(substr("Got template")) | ||
email_logger.debug.assert_called_with('Got template %s from database', template_name) | ||
self.assertEqual(eft.template_source, 'database') | ||
eft.render_message() | ||
to = ['[email protected]', '[email protected]'] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters