Stop populating the notification to sender mapping table when creating a notificaiton.

This commit is contained in:
Rebecca Law
2017-11-29 16:47:23 +00:00
parent 95fd1e8c31
commit 8aa94af5d7
11 changed files with 49 additions and 468 deletions

View File

@@ -7,21 +7,16 @@ from sqlalchemy.exc import SQLAlchemyError
from freezegun import freeze_time
from collections import namedtuple
from app.dao.service_email_reply_to_dao import dao_get_reply_to_by_service_id
from app.models import (
Notification,
NotificationHistory,
NotificationEmailReplyTo,
NotificationSmsSender,
ScheduledNotification,
Template
)
from app.notifications.process_notifications import (
create_content_for_notification,
persist_notification,
persist_email_reply_to_id_for_notification,
persist_scheduled_notification,
persist_sms_sender_id_for_notification,
send_notification_to_queue,
simulated_recipient
)
@@ -29,7 +24,6 @@ from notifications_utils.recipients import validate_and_format_phone_number, val
from app.utils import cache_key_for_service_template_counter
from app.v2.errors import BadRequestError
from tests.app.conftest import sample_api_key as create_api_key
from tests.app.db import create_reply_to_email, create_service_sms_sender
def test_create_content_for_notification_passes(sample_email_template):
@@ -452,27 +446,3 @@ def test_persist_email_notification_stores_normalised_email(
assert persisted_notification.to == recipient
assert persisted_notification.normalised_to == expected_recipient_normalised
def test_persist_email_reply_to_id_for_notification(sample_service, sample_notification):
create_reply_to_email(sample_service, "test@test.com")
reply_to_address = dao_get_reply_to_by_service_id(sample_service.id)
persist_email_reply_to_id_for_notification(sample_notification.id, reply_to_address[0].id)
email_reply_to = NotificationEmailReplyTo.query.all()
assert len(email_reply_to) == 1
assert email_reply_to[0].notification_id == sample_notification.id
assert email_reply_to[0].service_email_reply_to_id == reply_to_address[0].id
def test_persist_sms_sender_id_for_notification(sample_service, sample_notification):
sms_sender = create_service_sms_sender(service=sample_service, sms_sender="123456")
persist_sms_sender_id_for_notification(notification_id=sample_notification.id,
sms_sender_id=sms_sender.id)
notification_to_sms_sender = NotificationSmsSender.query.all()
assert len(notification_to_sms_sender) == 1
assert notification_to_sms_sender[0].notification_id == sample_notification.id
assert notification_to_sms_sender[0].service_sms_sender_id == sms_sender.id