Send notification emails on some http errors

This commit is contained in:
richard-dds
2019-05-15 14:31:16 -04:00
parent d8e75668b0
commit fe5def3a92
4 changed files with 26 additions and 8 deletions

View File

@@ -309,7 +309,7 @@ def mock_logger(app):
app.logger = real_logger
@pytest.fixture(scope="session", autouse=True)
@pytest.fixture(scope="function", autouse=True)
def notification_sender(app):
real_notification_sender = app.notification_sender
app.notification_sender = FakeNotificationSender()

View File

@@ -1,5 +1,7 @@
import pytest
from flask import url_for
from copy import copy
from tests.factories import UserFactory
@pytest.fixture
@@ -20,3 +22,16 @@ def test_csrf_error(csrf_enabled_app, client):
body = response.data.decode()
assert "Session Expired" in body
assert "Log in required" in body
def test_errors_generate_notifications(app, client, user_session, notification_sender):
user_session(UserFactory.create())
new_app = copy(app)
@new_app.route("/throw")
def throw():
raise ValueError()
new_app.test_client().get("/throw")
notification_sender.send.assert_called_once()

View File

@@ -42,4 +42,4 @@ class FakeLogger:
self.extras.append(kwargs["extra"])
FakeNotificationSender = Mock(spec=NotificationSender)
FakeNotificationSender = lambda: Mock(spec=NotificationSender)