fix: preserve request actions and soften test-mode mail failures

This commit is contained in:
Md Bayazid Bostame
2026-03-30 12:41:40 +02:00
parent ca9e890b0b
commit bce58b3f25
3 changed files with 46 additions and 8 deletions

View 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'],
)