Files
upbeatBytes/tests/test_email_reply_to.py
thejayman77 667b1a82c3 brand: standardize "Upbeat Bytes" → "upbeatBytes" everywhere
Per the logo + brand: the name is upbeatBytes (camelCase). Swept all user-facing
strings — titles/og:site_name/og:title, logo alt text, share pages (share.py),
emails (email_send), classifier prompt (llm), digest/unsubscribe (api), PWA
manifest, game share text, sign-in, the SPA shell + patch-static-heads (play
title) — plus README/publish.sh and the email test fixture. (SMTP From env was
already upbeatBytes.) Domains (upbeatbytes.com) unchanged. 425 BE + 36 FE green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 20:01:20 -04:00

49 lines
1.4 KiB
Python

import goodnews.email_send as es
class _FakeSMTP:
last = {}
def __init__(self, *a, **k):
pass
def __enter__(self):
return self
def __exit__(self, *a):
return False
def ehlo(self):
pass
def starttls(self, context=None):
pass
def login(self, *a):
pass
def send_message(self, msg):
_FakeSMTP.last = {"To": msg["To"], "Reply-To": msg["Reply-To"], "From": msg["From"]}
def _arm(monkeypatch):
monkeypatch.setenv("GOODNEWS_SMTP_HOST", "smtp.example.com")
monkeypatch.setattr(es.smtplib, "SMTP", _FakeSMTP)
def test_reply_to_uses_env_inbox(monkeypatch):
_arm(monkeypatch)
monkeypatch.setenv("GOODNEWS_REPLY_TO_EMAIL", "inbox@upbeatbytes.com")
es.send_feedback_reply("reader@x.com", "hello", "<p>hello</p>", "original?")
assert _FakeSMTP.last["Reply-To"] == "inbox@upbeatbytes.com"
assert _FakeSMTP.last["To"] == "reader@x.com" # reader is recipient
assert _FakeSMTP.last["Reply-To"] != "reader@x.com" # never the reader
def test_reply_to_falls_back_to_from(monkeypatch):
_arm(monkeypatch)
monkeypatch.delenv("GOODNEWS_REPLY_TO_EMAIL", raising=False)
monkeypatch.setenv("GOODNEWS_SMTP_FROM", "upbeatBytes <hello@upbeatbytes.com>")
es.send_feedback_reply("reader@x.com", "hi", None, "o")
assert _FakeSMTP.last["Reply-To"] == "upbeatBytes <hello@upbeatbytes.com>"