Add NotificationSender, one test

This commit is contained in:
richard-dds
2019-05-10 16:01:25 -04:00
parent 802c62e3e9
commit a6c5f484b9
6 changed files with 99 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import pytest
from unittest.mock import Mock
from tests.factories import NotificationRecipientFactory
from atst.utils.notification_sender import NotificationSender
@pytest.fixture
def mock_queue(queue):
return Mock(spec=queue)
@pytest.fixture
def notification_sender(mock_queue):
return NotificationSender(mock_queue)
def test_can_send_notification(mock_queue, notification_sender):
recipient_email = "test@example.com"
email_body = "This is a test"
NotificationRecipientFactory.create(email=recipient_email)
notification_sender.send(email_body)
mock_queue.send_mail.assert_called_once_with(
["test@example.com"], notification_sender.EMAIL_SUBJECT, email_body
)