fix: preserve request actions and soften test-mode mail failures
This commit is contained in:
28
backend/workflows/tests/test_email_workflows.py
Normal file
28
backend/workflows/tests/test_email_workflows.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from django.test import TestCase, override_settings
|
||||
|
||||
from workflows.email_workflows import send_workflow_email
|
||||
|
||||
|
||||
class SendWorkflowEmailTests(TestCase):
|
||||
@override_settings(EMAIL_TEST_MODE=True, EMAIL_TEST_REDIRECT='test@example.com')
|
||||
@patch('workflows.email_workflows.send_system_email', side_effect=ConnectionRefusedError('[Errno 111] Connection refused'))
|
||||
def test_test_mode_suppresses_smtp_connection_errors(self, _mock_send_system_email):
|
||||
send_workflow_email(
|
||||
subject='Test',
|
||||
body='Body',
|
||||
to=['real@example.com'],
|
||||
attachments=[Path('/tmp/test.pdf')],
|
||||
)
|
||||
|
||||
@override_settings(EMAIL_TEST_MODE=False)
|
||||
@patch('workflows.email_workflows.send_system_email', side_effect=ConnectionRefusedError('[Errno 111] Connection refused'))
|
||||
def test_non_test_mode_keeps_smtp_connection_errors(self, _mock_send_system_email):
|
||||
with self.assertRaises(ConnectionRefusedError):
|
||||
send_workflow_email(
|
||||
subject='Test',
|
||||
body='Body',
|
||||
to=['real@example.com'],
|
||||
)
|
||||
Reference in New Issue
Block a user