Files
aimsight-libredesk/tests/test_taches.py
T
maximeandClaude Opus 5.5 3e0b5d03a3 Relecture : le serveur ne construit jamais l image, réseau retenu par le .env, tâches arrêter
- docs/production.md : seuls compose.yml, compose.reseau.yml et verifier.py vont sur le serveur ; docker compose up -d --no-build ; COMPOSE_FILE dans ~/ollama/.env ; relance par Compose plutôt que docker start ; docker logout après le pull.
- verifier.py lisible par Python 3.8/3.9.
- Tâches « Instance de test : arrêter » et « Ollama : arrêter ».

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 09:57:55 +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 "base_connaissances.importer" 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()