072: regles automatiques eteintes par defaut (reglage regles_auto), plus de course ni de regle proposee automatiques
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XGaEeTZLvHXfYPUNWkgYoi
This commit is contained in:
1 parent
883b4e1745
commit
5d98d08a8b
6 files changed
+112
-5
No files matched your search
@@ -0,0 +1,37 @@
|
||||
import pytest
|
||||
from app import classifier as c
|
||||
from app.db import add_regle, get_classement
|
||||
|
||||
pytestmark = pytest.mark.regles_off
|
||||
|
||||
|
||||
def _mail(mid="m1", objet="Course Tunis demain", exp="collegue@tt.tn"):
|
||||
return {"message_id": mid, "objet": objet, "expediteur": exp, "apercu": "", "etiquettes": ["tunis"]}
|
||||
|
||||
|
||||
def test_defaut_eteint(temp_db):
|
||||
assert c.regles_auto_actives(temp_db) is False
|
||||
|
||||
|
||||
def test_aucune_regle_ne_classe(temp_db):
|
||||
add_regle(categorie="Tunis", expediteur="collegue@tt.tn", mot_cle="tunis", statut="active", db_path=temp_db)
|
||||
r = c.classify_mail(_mail(), db_path=temp_db)
|
||||
assert r["categorie"] == "À classer"
|
||||
|
||||
|
||||
def test_reactivation_reversible(temp_db):
|
||||
add_regle(categorie="Tunis", expediteur=None, mot_cle="tunis", statut="active", db_path=temp_db)
|
||||
c.regler_regles_auto(True, temp_db)
|
||||
assert c.classify_mail(_mail("m2"), db_path=temp_db)["categorie"] == "Tunis"
|
||||
c.regler_regles_auto(False, temp_db)
|
||||
assert c.classify_mail(_mail("m3"), db_path=temp_db)["categorie"] == "À classer"
|
||||
|
||||
|
||||
def test_correction_manuelle_ne_propose_pas_de_regle(temp_db):
|
||||
cl, regle = c.manual_classify_and_propose("m4", "Tunis", {"expediteur": "a@b.tn", "objet": "Course Tunis"}, db_path=temp_db)
|
||||
assert cl["source"] == "manuel" and regle is None
|
||||
|
||||
|
||||
def test_manuel_jamais_ecrase(temp_db):
|
||||
c.manual_classify_and_propose("m5", "Pb PO", {"expediteur": "a@b.tn", "objet": "x"}, db_path=temp_db)
|
||||
assert c.classify_mail(_mail("m5"), db_path=temp_db)["categorie"] == "Pb PO"
|
||||
Reference in new issue
Block a user