Tâches VS Code : tests, instance de test, Ollama, import (production avec confirmation)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maximeandClaude Opus 5.5 committed 2026-11-12 09:46:49 +01:00
1 parent 35da804fb3
commit 3dc71e9d31
2 files changed
+182

No files matched your search

+119
View File
@@ -0,0 +1,119 @@
{
"version": "2.0.0",
"options": { "cwd": "${workspaceFolder}" },
"tasks": [
{
"label": "Tests",
"type": "shell",
"command": "python3 -m unittest discover -s tests -v",
"group": { "kind": "test", "isDefault": true },
"problemMatcher": []
},
{
"label": "Instance de test : démarrer",
"type": "shell",
"command": "bash instance-de-test/demarrer.sh '${input:motDePasse}'",
"problemMatcher": []
},
{
"label": "Instance de test : préparer",
"type": "shell",
"command": "python3 instance-de-test/preparer.py '${input:motDePasse}'",
"problemMatcher": []
},
{
"label": "Instance de test : effacer",
"type": "shell",
"command": "[ \"${input:confirmation}\" = oui ] || { echo annulé; exit 1; } && docker compose -f instance-de-test/docker-compose.yml -p ldtest down -v",
"problemMatcher": []
},
{
"label": "Instance de test : brancher sur Ollama",
"type": "shell",
"command": "eval \"$(grep '^export ANTHROPIC_API_KEY=' .env)\" && python3 instance-de-test/configurer_ia.py '${input:motDePasse}' http://ollama:11434/v1 bge-m3:567m",
"problemMatcher": []
},
{
"label": "Instance de test : essai des brouillons",
"type": "shell",
"command": "python3 instance-de-test/essayer_brouillons.py '${input:motDePasse}'",
"problemMatcher": []
},
{
"label": "Instance de test : empreintes des extraits",
"type": "shell",
"command": "bash instance-de-test/empreintes.sh",
"problemMatcher": []
},
{
"label": "Ollama : construire",
"type": "shell",
"command": "docker compose -f ollama/compose.yml build",
"problemMatcher": []
},
{
"label": "Ollama : lancer (instance de test)",
"type": "shell",
"command": "RESEAU_LIBREDESK=ldtest_libredesk OLLAMA_PORT=11435 docker compose -f ollama/compose.yml -f ollama/compose.reseau.yml up -d",
"problemMatcher": []
},
{
"label": "Ollama : vérifier (poste, port 11435)",
"type": "shell",
"command": "python3 ollama/verifier.py http://127.0.0.1:11435/v1",
"problemMatcher": []
},
{
"label": "Import : simulation (instance de test)",
"type": "shell",
"command": "set -a && . instance-de-test/.env && set +a && python3 -m base_connaissances.importer",
"problemMatcher": []
},
{
"label": "Import : ÉCRIRE (instance de test)",
"type": "shell",
"command": "set -a && . instance-de-test/.env && set +a && python3 -m base_connaissances.importer --ecrire",
"problemMatcher": []
},
{
"label": "Import : simulation (PRODUCTION)",
"type": "shell",
"command": "set -a && . ./.env && set +a && LIBREDESK_URL='${input:urlProduction}' python3 -m base_connaissances.importer",
"problemMatcher": []
},
{
"label": "Import : ÉCRIRE (PRODUCTION)",
"type": "shell",
"command": "[ \"${input:confirmationProduction}\" = oui ] || { echo annulé; exit 1; } && set -a && . ./.env && set +a && LIBREDESK_URL='${input:urlProduction}' python3 -m base_connaissances.importer --ecrire",
"problemMatcher": []
}
],
"inputs": [
{
"id": "motDePasse",
"type": "promptString",
"description": "Mot de passe de l'utilisateur System de l'instance de test",
"default": "TestAdmin-2026!",
"password": true
},
{
"id": "urlProduction",
"type": "promptString",
"description": "Adresse de LibreDesk en PRODUCTION (les clés admin temporaires viennent de .env)"
},
{
"id": "confirmation",
"type": "pickString",
"description": "Effacer l'instance de test et toutes ses données ?",
"options": ["non", "oui"],
"default": "non"
},
{
"id": "confirmationProduction",
"type": "pickString",
"description": "ÉCRIRE dans la base de connaissances de la PRODUCTION ?",
"options": ["non", "oui"],
"default": "non"
}
]
}
+63
View File
@@ -0,0 +1,63 @@
"""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_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()