- Add comprehensive documentation for backend content rendering in AGENTS.md, detailing the new `render_content` and `render_title` Jinja globals built on mistune with media processing, emoji shortcodes, and XSS protection
- Document the `X-Response-Time` header and bottom-left render time indicator in README.md
- Update bot token pricing documentation to clarify fallback vs gateway cost headers
- Add `email_accounts` to soft-delete tables and `idx_users_role` composite index in database schema
- Implement `telegram_pairings` and `telegram_links` table creation with column migration and indexes
- Add `/profile/{username}/telegram` endpoint to docs API with request/unpair actions
- Register `TelegramService` in main.py lifespan and add `response_timing` middleware emitting `X-Response-Time` header
- Introduce `TelegramPairForm` model and `guard_public_host_sync` synchronous host validation function
60 lines
1.7 KiB
Python
60 lines
1.7 KiB
Python
# retoor <retoor@molodetz.nl>
|
|
|
|
from devplacepy.services.email.config import EmailAccount
|
|
|
|
|
|
def test_defaults_apply_imap_993_and_smtp_587():
|
|
account = EmailAccount.from_row({"username": "me@example.com"})
|
|
assert account.imap_port == 993
|
|
assert account.smtp_port == 587
|
|
|
|
|
|
def test_from_address_falls_back_to_username():
|
|
account = EmailAccount.from_row({"username": "me@example.com"})
|
|
assert account.from_address == "me@example.com"
|
|
|
|
|
|
def test_explicit_from_address_wins():
|
|
account = EmailAccount.from_row(
|
|
{"username": "login@example.com", "from_address": "public@example.com"}
|
|
)
|
|
assert account.from_address == "public@example.com"
|
|
|
|
|
|
def test_boolean_coercion_from_strings():
|
|
account = EmailAccount.from_row(
|
|
{
|
|
"imap_ssl": "true",
|
|
"imap_starttls": "0",
|
|
"smtp_ssl": "yes",
|
|
"smtp_starttls": "on",
|
|
}
|
|
)
|
|
assert account.imap_ssl is True
|
|
assert account.imap_starttls is False
|
|
assert account.smtp_ssl is True
|
|
assert account.smtp_starttls is True
|
|
|
|
|
|
def test_boolean_coercion_from_integers():
|
|
account = EmailAccount.from_row({"imap_ssl": 1, "smtp_ssl": 0})
|
|
assert account.imap_ssl is True
|
|
assert account.smtp_ssl is False
|
|
|
|
|
|
def test_port_coercion_falls_back_on_garbage():
|
|
account = EmailAccount.from_row({"imap_port": "not-a-port", "smtp_port": "2525"})
|
|
assert account.imap_port == 993
|
|
assert account.smtp_port == 2525
|
|
|
|
|
|
def test_missing_fields_become_empty_strings():
|
|
account = EmailAccount.from_row({})
|
|
assert account.label == ""
|
|
assert account.imap_host == ""
|
|
assert account.smtp_host == ""
|
|
assert account.username == ""
|
|
assert account.password == ""
|
|
assert account.from_address == ""
|
|
assert account.from_name == ""
|