"""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