atst/tests/utils/test_notification_sender.py
dandds d7478e322a Use Celery instead of RQ.
Celery provides a more robust set of queueing options for both tasks and
worker processes. Updates include:
- infrastructure necessary to run Celery, including celery entrypoint
- backgrounded functions are now imported directly from atst.jobs
- update tests as-needed
- update kubernetes worker pod command
2019-08-29 09:33:47 -04:00

25 lines
710 B
Python

import pytest
from unittest.mock import Mock
from tests.factories import NotificationRecipientFactory
from atst.utils.notification_sender import NotificationSender
@pytest.fixture
def notification_sender():
return NotificationSender()
def test_can_send_notification(monkeypatch, notification_sender):
job_mock = Mock()
monkeypatch.setattr("atst.jobs.send_notification_mail.delay", job_mock)
recipient_email = "test@example.com"
email_body = "This is a test"
NotificationRecipientFactory.create(email=recipient_email)
notification_sender.send(email_body)
job_mock.assert_called_once_with(
("test@example.com",), notification_sender.EMAIL_SUBJECT, email_body
)