Update notificaiton API endpoints to use template's reply_to

Sets the reply_to_text on notification from the template value if
it's set.
This commit is contained in:
Alexey Bezhan
2017-12-15 17:13:55 +00:00
parent 3b0790f950
commit a98e5247b8
4 changed files with 67 additions and 25 deletions

View File

@@ -18,6 +18,7 @@ from app.models import (
from tests.app.db import (
create_user,
create_reply_to_email,
create_letter_contact,
create_service,
create_template
)
@@ -217,7 +218,27 @@ def test_send_one_off_notification_should_add_email_reply_to_text_for_notificati
research_mode=False,
queue=None
)
notification.reply_to_text == reply_to_email.email_address
assert notification.reply_to_text == reply_to_email.email_address
def test_send_one_off_letter_notification_should_use_template_reply_to_text(sample_letter_template, celery_mock):
letter_contact = create_letter_contact(sample_letter_template.service, "Edinburgh, ED1 1AA", is_default=False)
sample_letter_template.reply_to = str(letter_contact.id)
data = {
'to': 'user@example.com',
'template_id': str(sample_letter_template.id),
'created_by': str(sample_letter_template.service.created_by_id)
}
notification_id = send_one_off_notification(service_id=sample_letter_template.service.id, post_data=data)
notification = Notification.query.get(notification_id['id'])
celery_mock.assert_called_once_with(
notification=notification,
research_mode=False,
queue=None
)
assert notification.reply_to_text == "Edinburgh, ED1 1AA"
def test_send_one_off_notification_should_throw_exception_if_reply_to_id_doesnot_exist(