Add test to use backup server

This commit is contained in:
Adrià Casajús 2025-07-30 14:47:23 +02:00 committed by Adrià Casajús
parent 3c9b7582da
commit 3c8b5c8f5b

View file

@ -143,6 +143,22 @@ def test_mail_sender_try_several_servers():
config.NOT_SEND_EMAIL = True
def test_mail_sender_try_backup_postfix():
port_closed = closed_dummy_server()
port_ok = smtp_response_server("250 Ok")()
original_postfix_server = config.POSTFIX_SERVERS
config.POSTFIX_SERVERS = [f"localhost:{port_closed}"]
config.POSTFIX_BACKUP_SERVERS = [f"localhost:{port_ok}"]
config.NOT_SEND_EMAIL = False
config.POSTFIX_SUBMISSION_TLS = False
send_request = create_dummy_send_request()
try:
assert mail_sender.send(send_request, 0)
finally:
config.POSTFIX_SERVERS = original_postfix_server
config.NOT_SEND_EMAIL = True
@mail_sender.store_emails_test_decorator
def test_send_unsent_email_from_fs():
original_postfix_server = config.POSTFIX_SERVERS