072: file A valider, contexte de fil (Thread-Index), fil dans la lecture, filtre informations dans Suivi
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
5d98d08a8b
commit
c7c28f4079
5 files changed
+337
-16
No files matched your search
@@ -0,0 +1,58 @@
|
||||
import pytest
|
||||
from app import analyse as a
|
||||
from app.classifier import manual_classify_and_propose
|
||||
from app.config import get_tunis_now_iso
|
||||
from app.db import list_courses, get_classement
|
||||
|
||||
pytestmark = pytest.mark.regles_off
|
||||
|
||||
|
||||
def _fiche(cat="Pb PO", course=None):
|
||||
return {"categorie": cat, "confiance": "haute", "resume": "Resume.", "course": course,
|
||||
"demande": {"reelle": False, "action": "", "echeance": ""}}
|
||||
|
||||
|
||||
def _maintenant():
|
||||
return get_tunis_now_iso()[:19]
|
||||
|
||||
|
||||
def test_proposition_categorie_puis_acceptation(temp_db):
|
||||
a.enregistrer("m1", _fiche(), "PO 123", "x@tt.tn", _maintenant(), temp_db)
|
||||
items = a.a_valider(db_path=temp_db)
|
||||
assert [(i["type"], i["propose"]) for i in items] == [("categorie", "Pb PO")]
|
||||
a.decider("m1", "categorie", "accepter", temp_db)
|
||||
c = get_classement("m1", temp_db)
|
||||
assert c["categorie"] == "Pb PO" and c["source"] == "manuel"
|
||||
assert a.a_valider(db_path=temp_db) == []
|
||||
|
||||
|
||||
def test_refus_ne_revient_pas(temp_db):
|
||||
a.enregistrer("m2", _fiche("Box 5G"), "Box", "x@tt.tn", _maintenant(), temp_db)
|
||||
a.decider("m2", "categorie", "refuser", temp_db)
|
||||
assert a.a_valider(db_path=temp_db) == []
|
||||
assert get_classement("m2", temp_db) is None or get_classement("m2", temp_db)["categorie"] == "À classer"
|
||||
|
||||
|
||||
def test_classement_manuel_jamais_propose(temp_db):
|
||||
manual_classify_and_propose("m3", "Tunis", {"expediteur": "a@b", "objet": "x"}, db_path=temp_db)
|
||||
a.enregistrer("m3", _fiche("Pb PO"), "x", "a@b", _maintenant(), temp_db)
|
||||
assert a.a_valider(db_path=temp_db) == []
|
||||
|
||||
|
||||
def test_course_acceptee_creee_une_fois(temp_db):
|
||||
course = {"objets": ["dossier signé"], "documents": [], "sens": "sfax_tunis"}
|
||||
a.enregistrer("m4", _fiche("À classer", course), "Dossier", "x@tt.tn", _maintenant(), temp_db)
|
||||
items = a.a_valider(db_path=temp_db)
|
||||
assert [(i["type"], i["sens"]) for i in items] == [("course", "sfax_tunis")]
|
||||
r = a.decider("m4", "course", "accepter", temp_db)
|
||||
assert r["course"]["message_id"] == "m4"
|
||||
assert len([k for k in list_courses(None, db_path=temp_db) if k["message_id"] == "m4"]) == 1
|
||||
assert a.a_valider(db_path=temp_db) == []
|
||||
|
||||
|
||||
def test_decision_invalide(temp_db):
|
||||
a.enregistrer("m5", _fiche(), "x", "x", _maintenant(), temp_db)
|
||||
with pytest.raises(ValueError):
|
||||
a.decider("m5", "autre", "accepter", temp_db)
|
||||
with pytest.raises(LookupError):
|
||||
a.decider("inconnu", "categorie", "accepter", temp_db)
|
||||
Reference in new issue
Block a user