Files
maximeandClaude Opus 5.5 10ed887417 Noms plus clairs : snippets/, scripts de test numérotés, verifier_ollama.py
- base_connaissances/ → snippets/ (corpus/ → textes/, instructions.md → consignes_redaction.md, decoupage.py → fichiers.py, importer.py → envoyer.py) ; python3 -m snippets.envoyer.
- instance-de-test/ : 1_demarrer.sh, 2_creer_boite_et_cle.py, 3_brancher_ia.py, 4_essayer_brouillons.py, voir_empreintes.sh, connexion_admin.py.
- ollama/verifier.py → ollama/verifier_ollama.py ; tests, tâches VS Code et docs alignés.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 10:27:06 +01:00

38 lines
2.1 KiB
Python

"""Prépare une instance de test neuve : la boîte e-mail « Test » (SMTP = Mailpit, rien ne sort) et l'agent
« Import base » (rôle Admin) avec sa clé. Écrase instance-de-test/.env (LIBREDESK_URL, LIBREDESK_ADMIN_KEY,
LIBREDESK_ADMIN_SECRET). S'arrête si l'instance est déjà préparée.
python3 instance-de-test/2_creer_boite_et_cle.py <mot de passe System>
"""
import sys
from pathlib import Path
from connexion_admin import B, connexion, req
SMTP = {"enabled": True, "host": "mailpit", "port": 1025, "username": "", "password": "", "auth_protocol": "none",
"tls_type": "none", "max_conns": 1, "max_msg_retries": 0, "idle_timeout": "5s", "pool_wait_timeout": "5s",
"hello_hostname": ""}
IMAP = {"host": "127.0.0.1", "port": 1, "username": "x", "password": "x", "mailbox": "INBOX", "read_interval": "1h",
"scan_inbox_since": "1h", "tls_type": "none"}
def main(mot_de_passe: str) -> None:
connexion(mot_de_passe)
if any(b["name"] == "Test" for b in req("GET", "/api/v1/inboxes") or []):
sys.exit("instance déjà préparée : docker compose -p ldtest down -v, puis 1_demarrer.sh")
req("POST", "/api/v1/inboxes", {"name": "Test", "channel": "email", "enabled": True, "csat_enabled": False,
"from": "Support <support@example.com>",
"config": {"auth_type": "password", "from": "Support <support@example.com>",
"smtp": [SMTP], "imap": [IMAP]}})
agent = req("POST", "/api/v1/agents", {"first_name": "Import", "last_name": "base", "email": "import@example.com",
"roles": ["Admin"], "send_welcome_email": False, "enabled": True})
cle = req("POST", f"/api/v1/agents/{agent['id']}/api-key")
env = Path(__file__).with_name(".env")
env.write_text(f"LIBREDESK_URL={B}\nLIBREDESK_ADMIN_KEY={cle['api_key']}\n"
f"LIBREDESK_ADMIN_SECRET={cle['api_secret']}\n")
print(f"prête : boîte « Test » (SMTP = Mailpit), clé d'import dans {env}")
if __name__ == "__main__":
main(*sys.argv[1:2])