Mock out app NotificationSender during testing
This commit is contained in:
parent
97b9d84c38
commit
9e97df79f5
@ -12,7 +12,7 @@ from atst.database import db as _db
|
||||
from atst.queue import queue as atst_queue
|
||||
import tests.factories as factories
|
||||
from tests.mocks import PDF_FILENAME, PDF_FILENAME2
|
||||
from tests.utils import FakeLogger
|
||||
from tests.utils import FakeLogger, FakeNotificationSender
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from cryptography.hazmat.primitives.asymmetric import rsa
|
||||
@ -307,3 +307,13 @@ def mock_logger(app):
|
||||
yield app.logger
|
||||
|
||||
app.logger = real_logger
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_notification_sender(app):
|
||||
real_notification_sender = app.notification_sender
|
||||
app.notification_sender = FakeNotificationSender()
|
||||
|
||||
yield app.notification_sender
|
||||
|
||||
app.notification_sender = real_notification_sender
|
||||
|
@ -1,5 +1,8 @@
|
||||
from flask import template_rendered
|
||||
from contextlib import contextmanager
|
||||
from unittest.mock import Mock
|
||||
|
||||
from atst.utils.notification_sender import NotificationSender
|
||||
|
||||
|
||||
@contextmanager
|
||||
@ -37,3 +40,6 @@ class FakeLogger:
|
||||
self.messages.append(msg)
|
||||
if "extra" in kwargs:
|
||||
self.extras.append(kwargs["extra"])
|
||||
|
||||
|
||||
FakeNotificationSender = Mock(spec=NotificationSender)
|
||||
|
Loading…
x
Reference in New Issue
Block a user