"""EmailService — Postmark client + dev-mode logging fallback.""" from __future__ import annotations import logging from unittest.mock import patch import httpx import pytest from app.email import ( EmailDeliveryError, LicenseEmail, LoggingEmailService, PostmarkEmailService, _render_html, _render_text, get_email_service, ) def _msg() -> LicenseEmail: return LicenseEmail( to_name="Jane Doe", to_email="jane@example.com", tier="core", license_key="DT1-CORE-aaaa-bbbb", expires_at_iso="2027-05-14T01:00:00Z", blob="DTLIC2:placeholder", ) def test_render_text_contains_essentials(): body = _render_text(_msg()) assert "Jane Doe" in body assert "DTLIC2:placeholder" in body assert "DT1-CORE-aaaa-bbbb" in body assert "core" in body assert "2027-05-14" in body def test_render_html_escapes_user_input(): msg = LicenseEmail( to_name="", to_email="x@y.com", tier="core", license_key="K", expires_at_iso="2030-01-01T00:00:00Z", blob="DTLIC2:x", ) html = _render_html(msg) assert "