atst/tests/utils/test_notification_sender.py
2019-05-15 14:57:46 -04:00

28 lines
725 B
Python

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_notification_mail.assert_called_once_with(
("test@example.com",), notification_sender.EMAIL_SUBJECT, email_body
)