Added email functionality
Build LinkLog Development Image / development-image (push) Successful in 10s

This commit is contained in:
Olaf
2026-08-25 22:27:45 +02:00
parent bd78e3b86e
commit 07e520e03f
13 changed files with 228 additions and 8 deletions
+28
View File
@@ -0,0 +1,28 @@
## Copyright © 2026 Olaf Kolkman
## SPDX-License-Identifier: GPL-3.0-or-later
from unittest.mock import patch
from backend.app.services.email_service import send_verification_email
def test_send_verification_email_uses_smtp_settings(monkeypatch):
from backend.app.core.config import settings
monkeypatch.setattr(settings, 'smtp_host', 'smtp.example.com')
monkeypatch.setattr(settings, 'smtp_port', 587)
monkeypatch.setattr(settings, 'smtp_from', 'LinkLog <no-reply@example.com>')
monkeypatch.setattr(settings, 'smtp_username', 'mailer')
monkeypatch.setattr(settings, 'smtp_password', 'secret')
monkeypatch.setattr(settings, 'smtp_use_tls', True)
with patch('backend.app.services.email_service.SMTP') as smtp_class:
smtp = smtp_class.return_value.__enter__.return_value
send_verification_email('user@example.com', 'user', 'https://linklog.example/verify')
smtp_class.assert_called_once_with('smtp.example.com', 587, timeout=10)
smtp.starttls.assert_called_once_with()
smtp.login.assert_called_once_with('mailer', 'secret')
message = smtp.send_message.call_args.args[0]
assert message['To'] == 'user@example.com'
assert 'https://linklog.example/verify' in message.get_content()