Files
aimsight-libredesk/tests/test_taches.py
T
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

69 lines
2.9 KiB
Python

"""Les tâches VS Code : aucune n'écrit en production sans adresse tapée et confirmation (design §5)."""
import json
import re
import unittest
from pathlib import Path
DEPOT = Path(__file__).resolve().parents[1]
TACHES = DEPOT / ".vscode" / "tasks.json"
CONFIRMATION_PRODUCTION = '[ "${input:confirmationProduction}" = oui ]'
def charger() -> dict:
return json.loads(TACHES.read_text(encoding="utf-8"))
def commandes() -> dict[str, str]:
return {t["label"]: t["command"] for t in charger()["tasks"]}
class TestTaches(unittest.TestCase):
def test_json_valide_et_libelles_uniques(self):
libelles = [t["label"] for t in charger()["tasks"]]
self.assertEqual(len(libelles), len(set(libelles)))
self.assertIn("Tests", libelles)
def test_ecriture_production_demande_confirmation(self):
ecritures = {l: c for l, c in commandes().items() if "--ecrire" in c and "urlProduction" in c}
self.assertTrue(ecritures, "aucune tâche d'écriture en production trouvée")
for libelle, c in ecritures.items():
self.assertIn(CONFIRMATION_PRODUCTION, c, libelle)
self.assertLess(c.index(CONFIRMATION_PRODUCTION), c.index("--ecrire"), libelle)
def test_url_production_sans_defaut(self):
entree = next(i for i in charger()["inputs"] if i["id"] == "urlProduction")
self.assertNotIn("default", entree)
def test_confirmations_non_par_defaut(self):
for i in charger()["inputs"]:
if i["id"].startswith("confirmation"):
self.assertEqual(i["default"], "non", i["id"])
def test_taches_instance_de_test_ne_visent_pas_la_production(self):
for libelle, c in commandes().items():
if "instance de test" in libelle.lower():
self.assertNotIn("urlProduction", c, libelle)
def test_import_instance_de_test_lit_son_env(self):
for libelle, c in commandes().items():
if "snippets.envoyer" in c and "instance de test" in libelle.lower():
self.assertIn("instance-de-test/.env", c, libelle)
def test_effacer_l_instance_demande_confirmation(self):
c = next(c for l, c in commandes().items() if "down -v" in c)
self.assertIn('[ "${input:confirmation}" = oui ]', c)
def test_arreter_sans_effacer(self): # design §5 : démarrage ET arrêt de l'instance de test
cmds = list(commandes().values())
self.assertTrue(any("-p ldtest stop" in c for c in cmds), "pas de tâche qui arrête l'instance de test")
self.assertTrue(any("ollama/compose.yml" in c and " stop" in c for c in cmds), "pas de tâche qui arrête Ollama")
def test_scripts_references_existent(self):
for libelle, c in commandes().items():
for chemin in re.findall(r"(?:instance-de-test|ollama)/[\w.-]+\.(?:py|sh|yml)", c):
self.assertTrue((DEPOT / chemin).exists(), f"{chemin} ({libelle})")
if __name__ == "__main__":
unittest.main()