Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XGaEeTZLvHXfYPUNWkgYoi
36 lines
1.6 KiB
Python
36 lines
1.6 KiB
Python
import pytest
|
|
from app import analyse as a
|
|
from app.classifier import manual_classify_and_propose
|
|
|
|
pytestmark = pytest.mark.regles_off
|
|
|
|
|
|
def _f(cat, resume="R."):
|
|
return {"categorie": cat, "confiance": "haute", "resume": resume, "course": None,
|
|
"demande": {"reelle": False, "action": "", "echeance": ""}}
|
|
|
|
|
|
def test_exemples_max_par_categorie_et_pas_de_corps(temp_db):
|
|
for i in range(5):
|
|
manual_classify_and_propose("t%d" % i, "Tunis", {"expediteur": "a@b", "objet": "Course %d" % i}, db_path=temp_db)
|
|
manual_classify_and_propose("p1", "Pb PO", {"expediteur": "c@d", "objet": "PO 1"}, db_path=temp_db)
|
|
ex = a.exemples_nabil(temp_db)
|
|
assert ex.count("=> Tunis") == 3 and "=> Pb PO" in ex
|
|
|
|
|
|
def test_refus_devient_contre_exemple_et_stats(temp_db):
|
|
a.enregistrer("m1", _f("Box 5G"), "Rapport regional", "x@tt.tn", "2026-11-21T09:00:00", temp_db)
|
|
a.decider("m1", "categorie", "refuser", temp_db)
|
|
assert "PAS Box 5G" in a.exemples_nabil(temp_db)
|
|
a.enregistrer("m2", _f("CI"), "Travaux", "x@tt.tn", "2026-11-21T09:00:00", temp_db)
|
|
a.decider("m2", "categorie", "accepter", temp_db)
|
|
st = a.stats_acceptation(temp_db)
|
|
assert st["total"] == {"acceptees": 1, "refusees": 1}
|
|
assert st["categories"]["CI"]["acceptees"] == 1 and st["categories"]["Box 5G"]["refusees"] == 1
|
|
|
|
|
|
def test_prompt_inclut_exemples_sans_imposer_de_regle():
|
|
m = a.construire_messages("o", "e", "c", ["Tunis"], "", "- x | y => Tunis")
|
|
assert "Exemples de choix reels" in m[0]["content"] and "autre categorie un autre jour" in m[0]["content"]
|
|
assert "Exemples de choix reels" not in a.construire_messages("o", "e", "c", ["Tunis"])[0]["content"]
|