Add NotificationSender, one test
This commit is contained in:
27
tests/utils/test_notification_sender.py
Normal file
27
tests/utils/test_notification_sender.py
Normal 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
|
||||
)
|
Reference in New Issue
Block a user