human hand off fix

This commit is contained in:
debu-2 2026-10-06 07:42:41 +05:30
parent 7b9e574b86
commit 0981262612
5 changed files with 154 additions and 24 deletions

View file

@ -49,6 +49,33 @@ def test_format_sender_with_name():
)
def test_quoted_history_uses_original_sender_not_human_owner():
from datetime import datetime, timezone
from app.services.handoff_email_templates import (
attach_quoted_history,
build_gmail_quote,
)
quoted_text, quoted_html = build_gmail_quote(
sender={"name": "Parth Dixit", "address": "parthdixit091@gmail.com"},
event_at=datetime(2026, 10, 6, 7, 29, tzinfo=timezone.utc),
body_text="sender: C",
body_html="<div>sender: C</div>",
)
body_text, body_html = attach_quoted_history(
new_text="responder: D",
new_html="<div>responder: D</div>",
quoted_text=quoted_text,
quoted_html=quoted_html,
)
assert body_text.startswith("responder: D")
assert "Parth Dixit <parthdixit091@gmail.com>" in body_text
assert "> sender: C" in body_text
assert "parthdixit091@gmail.com" in body_html
assert "Suyash AIML" not in body_text
def test_external_threading_headers_from_customer_message():
parent = {
"_id": "mongo-id",