Un client poate avea mai multi angajati care scriu pe WhatsApp de pe numere diferite; toti gasesc acum acelasi profil (rag/client.py, ~/.maria-bridge/clients.json). Profilul intra in prompt sub o sectiune DESPRE CLIENT, la fiecare mesaj, stateless ca restul Mariei — dar nu atinge cautarea/scorul din rag/rank.py, ca sa nu strice pragurile deja calibrate. Administrare din dashboard (sectiune noua "Clienti cunoscuti"), nu din chat, ca sa ramana pe canalul autentificat. 117/117 teste maria-whatsapp-bridge + teste noi pentru rutele de dashboard. Co-Authored-By: Claude Agent <noreply@anthropic.com>
54 lines
2.1 KiB
Python
54 lines
2.1 KiB
Python
"""Profil de client (firma): mai multe numere -> acelasi profil, fara istoric."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import client
|
|
import consumer
|
|
|
|
|
|
def test_doua_numere_acelasi_client_dau_acelasi_profil():
|
|
client.salveaza("acme", "ACME SRL", "Firma de distributie.", ["40712345678", "40799887766"])
|
|
assert client.profil("40712345678@s.whatsapp.net") == "Firma de distributie."
|
|
assert client.profil("40799887766@s.whatsapp.net") == "Firma de distributie."
|
|
|
|
|
|
def test_numar_neasociat_da_none():
|
|
client.salveaza("acme", "ACME SRL", "Firma de distributie.", ["40712345678"])
|
|
assert client.profil("40700000000@s.whatsapp.net") is None
|
|
|
|
|
|
def test_dupa_stergere_numerele_nu_mai_gasesc_clientul():
|
|
client.salveaza("acme", "ACME SRL", "Firma de distributie.", ["40712345678", "40799887766"])
|
|
assert client.sterge("acme") is True
|
|
assert client.profil("40712345678@s.whatsapp.net") is None
|
|
assert client.profil("40799887766@s.whatsapp.net") is None
|
|
|
|
|
|
def test_normalizare_la_scriere():
|
|
client.salveaza("acme", "ACME SRL", "Firma de distributie.", ["+40 712 345 678"])
|
|
assert client.profil("40712345678@s.whatsapp.net") == "Firma de distributie."
|
|
|
|
|
|
def test_numar_din_mesaj_grup_vs_fara_participant():
|
|
msg_grup = {"from": "1203xxx@g.us", "participant": "40712345678@s.whatsapp.net"}
|
|
assert client.numar(msg_grup) == "40712345678"
|
|
msg_grup_fara = {"from": "1203xxx@g.us"}
|
|
assert client.numar(msg_grup_fara) == ""
|
|
|
|
|
|
def test_fisier_lipsa_sau_corupt_nu_ridica_exceptie():
|
|
assert client.profil("40712345678@s.whatsapp.net") is None
|
|
import config
|
|
config.STATE_DIR.mkdir(parents=True, exist_ok=True)
|
|
config.CLIENTS_FILE.write_text("nu e json valid {{{", encoding="utf-8")
|
|
assert client.profil("40712345678@s.whatsapp.net") is None
|
|
|
|
|
|
def test_mesaje_llm_fara_profil_neschimbat():
|
|
mesaje_vechi = [
|
|
{"role": "system", "content": consumer.SYSTEM_PROMPT},
|
|
{"role": "user", "content": "CONTEXT:\nun chunk\n\nINTREBARE:\nintrebarea"},
|
|
]
|
|
mesaje_noi = consumer.mesaje_llm(["un chunk"], "intrebarea", None, profil=None)
|
|
assert mesaje_noi == mesaje_vechi
|