Select only recipient emails from the db
This commit is contained in:
parent
d3b42d5bfc
commit
97b9d84c38
@ -1,4 +1,5 @@
|
|||||||
from logging import Logger
|
from logging import Logger
|
||||||
|
from sqlalchemy import select
|
||||||
|
|
||||||
from atst.queue import ATSTQueue
|
from atst.queue import ATSTQueue
|
||||||
from atst.database import db
|
from atst.database import db
|
||||||
@ -22,7 +23,5 @@ class NotificationSender(object):
|
|||||||
self.queue.send_mail(recipients, self.EMAIL_SUBJECT, body)
|
self.queue.send_mail(recipients, self.EMAIL_SUBJECT, body)
|
||||||
|
|
||||||
def _get_recipients(self, type_):
|
def _get_recipients(self, type_):
|
||||||
return [
|
query = select([NotificationRecipient.email])
|
||||||
recipient.email
|
return db.session.execute(query).fetchone()
|
||||||
for recipient in db.session.query(NotificationRecipient).all()
|
|
||||||
]
|
|
||||||
|
@ -23,5 +23,5 @@ def test_can_send_notification(mock_queue, notification_sender):
|
|||||||
notification_sender.send(email_body)
|
notification_sender.send(email_body)
|
||||||
|
|
||||||
mock_queue.send_mail.assert_called_once_with(
|
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
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user