docs(tests): stratégie et scripts shell paramétrables\n\n- Upload 50Mo (anti-413)\n- OCR CNI (SAMPLE_CNI,FOLDER_HASH)\n- Enrichissement Adresse (FOLDER_HASH,FILE_HASH)\n- SKIP si prérequis manquants
This commit is contained in:
parent
e5a7b3874f
commit
9712d9f375
45
docs/TESTS.md
Normal file
45
docs/TESTS.md
Normal file
@ -0,0 +1,45 @@
|
||||
---
|
||||
title: Stratégie de tests (shell)
|
||||
---
|
||||
|
||||
# Objectif
|
||||
|
||||
Fournir des tests shell simples, paramétrables par variables d’environnement, pour valider les fonctionnalités clés sans dépendre d’outils lourds.
|
||||
|
||||
# Pré-requis
|
||||
|
||||
- Backend accessible sur `http://localhost:3001`
|
||||
- PM2 (optionnel) pour relancer le backend
|
||||
|
||||
# Tests disponibles
|
||||
|
||||
1) Upload volumineux (50 Mo): `tests/upload_100mb.test.sh`
|
||||
- Valide l’absence d’erreur 413 côté proxy et Multer
|
||||
|
||||
2) OCR CNI (paramétrable): `tests/ocr_cni_pipeline.test.sh`
|
||||
- Variables requises:
|
||||
- `SAMPLE_CNI` (chemin vers une image CNI)
|
||||
- `FOLDER_HASH` (hash du dossier cible)
|
||||
- Skips si variables non définies
|
||||
|
||||
3) Enrichissement Adresse (paramétrable): `tests/enrich_address_pipeline.test.sh`
|
||||
- Variables requises:
|
||||
- `FOLDER_HASH`, `FILE_HASH` (doit référencer un document déjà extrait avec au moins une adresse)
|
||||
- Skips si variables non définies
|
||||
|
||||
# Exécution
|
||||
|
||||
```
|
||||
chmod +x tests/*.sh
|
||||
./tests/upload_100mb.test.sh
|
||||
SAMPLE_CNI=/chemin/cni.jpg FOLDER_HASH=default ./tests/ocr_cni_pipeline.test.sh
|
||||
FOLDER_HASH=xxxx FILE_HASH=yyyy ./tests/enrich_address_pipeline.test.sh
|
||||
```
|
||||
|
||||
# Interprétation
|
||||
|
||||
- OK: test validé
|
||||
- SKIP: conditions non remplies (variables/env ou données manquantes)
|
||||
- ERR: action attendue non réalisée
|
||||
|
||||
|
||||
@ -24,4 +24,3 @@ extraction.entities.addresses[i].enrichment.address = {
|
||||
```
|
||||
|
||||
PDF: synthèse (adresse normalisée, mini-carte, risques) + parcelles.
|
||||
|
||||
|
||||
@ -24,4 +24,3 @@ extraction.entities.persons[i].enrichment.bodacc = {
|
||||
PDF: une page de synthèse (identité + hits) + annexes si autorisé.
|
||||
|
||||
Limites: homonymies; respecter le cadre légal (RGPD) et citer les sources.
|
||||
|
||||
|
||||
@ -23,4 +23,3 @@ extraction.entities.companies[i].enrichment.company = {
|
||||
PDF: synthèse (identité, dirigeants) + annexes Kbis si autorisé, sinon résumé horodaté + liens sources.
|
||||
|
||||
Conformité: respecter CGU, citer les sources, logs de collecte.
|
||||
|
||||
|
||||
29
tests/enrich_address_pipeline.test.sh
Executable file
29
tests/enrich_address_pipeline.test.sh
Executable file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ -z "${FOLDER_HASH:-}" || -z "${FILE_HASH:-}" ]]; then
|
||||
echo "[SKIP] Définir FOLDER_HASH et FILE_HASH pour exécuter ce test"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "[TEST] Enrichissement adresse pour $FILE_HASH dans $FOLDER_HASH"
|
||||
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST http://localhost:3001/api/folders/$FOLDER_HASH/files/$FILE_HASH/enrich/address || true)
|
||||
|
||||
if [[ "$HTTP_CODE" != "200" ]]; then
|
||||
echo "[ERR] Démarrage enrichissement refusé (HTTP $HTTP_CODE)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[OK] Enrichissement démarré (HTTP 200). Lecture du statut dans 3s..."
|
||||
sleep 3
|
||||
|
||||
STATUS_PATH="cache/$FOLDER_HASH/${FILE_HASH}.enrich.address.json"
|
||||
if [[ -f "$STATUS_PATH" ]]; then
|
||||
echo "[OK] Statut trouvé: $(jq -r .state "$STATUS_PATH" 2>/dev/null || echo unknown)"
|
||||
exit 0
|
||||
else
|
||||
echo "[ERR] Statut introuvable: $STATUS_PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
25
tests/ocr_cni_pipeline.test.sh
Executable file
25
tests/ocr_cni_pipeline.test.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ -z "${SAMPLE_CNI:-}" || -z "${FOLDER_HASH:-}" ]]; then
|
||||
echo "[SKIP] Définir SAMPLE_CNI et FOLDER_HASH pour exécuter ce test"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ ! -f "$SAMPLE_CNI" ]]; then
|
||||
echo "[ERR] SAMPLE_CNI introuvable: $SAMPLE_CNI" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[TEST] OCR CNI via /api/extract (folderHash=$FOLDER_HASH)"
|
||||
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -F "document=@$SAMPLE_CNI" -F "folderHash=$FOLDER_HASH" http://localhost:3001/api/extract || true)
|
||||
|
||||
if [[ "$HTTP_CODE" == "200" || "$HTTP_CODE" == "201" || "$HTTP_CODE" == "202" ]]; then
|
||||
echo "[OK] Extraction acceptée (HTTP $HTTP_CODE)"
|
||||
exit 0
|
||||
else
|
||||
echo "[ERR] Extraction refusée (HTTP $HTTP_CODE)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user