| from __future__ import annotations |
|
|
| from app.prompts import build_system_prompt |
|
|
|
|
| def test_system_prompt_includes_rules_and_brand(): |
| p = build_system_prompt("TOORX Assist") |
| assert "TOORX Assist" in p |
| |
| assert "RULE #1" in p |
| assert "language" in p.lower() |
| |
| pinned = build_system_prompt("X", language="portugués de Portugal (pt-PT)") |
| assert "pt-PT" in pinned |
| |
| assert "invent" in p.lower() |
| |
| assert "email" in p.lower() and "order number" in p.lower() and "postal code" in p.lower() |
| assert "NEVER" in p |
| |
| assert "escalate_to_human" in p |
| assert "search_knowledge" in p and "search_products" in p and "lookup_order" in p |
| |
| assert "emoji" in p.lower() |
| assert "variant_ids" in p |
|
|
|
|
| def test_system_prompt_default_brand(): |
| assert "Asistente" in build_system_prompt("") |
|
|
|
|
| def test_prompt_channel_handoff_is_mutually_exclusive(): |
| web = build_system_prompt("X", channel="web") |
| wa = build_system_prompt("X", channel="whatsapp") |
| assert "show_form" in web and "WhatsApp" not in web |
| assert "WhatsApp" in wa and "show_form" not in wa |
|
|
|
|
| def test_brand_name_braces_are_sanitized(): |
| |
| p = build_system_prompt("Acme {evil}") |
| assert "{evil}" not in p |
| assert "Acme" in p |
|
|