Refactor configuration handling and improve error management across services; normalize placeholder values for SMTP and Stripe configurations; enhance local storage fallback logic in StorageService; add tests for new behaviors and edge cases.
This commit is contained in:
19
backend/tests/test_email_service.py
Normal file
19
backend/tests/test_email_service.py
Normal file
@@ -0,0 +1,19 @@
|
||||
"""Tests for SMTP configuration normalization."""
|
||||
from app.services.email_service import send_email
|
||||
|
||||
|
||||
def test_placeholder_smtp_host_is_treated_as_unconfigured(app, monkeypatch):
|
||||
"""A copied sample SMTP host should not trigger a network call."""
|
||||
with app.app_context():
|
||||
app.config.update({
|
||||
"SMTP_HOST": "smtp.your-provider.com",
|
||||
"SMTP_PORT": 587,
|
||||
"SMTP_USER": "noreply@dociva.io",
|
||||
"SMTP_PASSWORD": "replace-with-smtp-password",
|
||||
})
|
||||
|
||||
def fail_if_called(*args, **kwargs):
|
||||
raise AssertionError("SMTP should not be contacted for placeholder config")
|
||||
|
||||
monkeypatch.setattr("smtplib.SMTP", fail_if_called)
|
||||
assert send_email("user@example.com", "Subject", "<p>Body</p>") is False
|
||||
Reference in New Issue
Block a user