Select only recipient emails from the db

This commit is contained in:
richard-dds 2019-05-15 10:17:03 -04:00
parent d3b42d5bfc
commit 97b9d84c38
2 changed files with 4 additions and 5 deletions

View File

@ -1,4 +1,5 @@
from logging import Logger
from sqlalchemy import select
from atst.queue import ATSTQueue
from atst.database import db
@ -22,7 +23,5 @@ class NotificationSender(object):
self.queue.send_mail(recipients, self.EMAIL_SUBJECT, body)
def _get_recipients(self, type_):
return [
recipient.email
for recipient in db.session.query(NotificationRecipient).all()
]
query = select([NotificationRecipient.email])
return db.session.execute(query).fetchone()

View File

@ -23,5 +23,5 @@ def test_can_send_notification(mock_queue, notification_sender):
notification_sender.send(email_body)
mock_queue.send_mail.assert_called_once_with(
["test@example.com"], notification_sender.EMAIL_SUBJECT, email_body
("test@example.com",), notification_sender.EMAIL_SUBJECT, email_body
)