Files

42 lines
1.2 KiB
Python

"""Selbsttest für Pingognito - ohne externe Testabhängigkeiten.
Aufruf:
python backend/selftest.py
Prüft Regelwerke, Datenbank-Roundtrip, Scope-Gate, Scanner und Report-Ausgabe.
Rückgabewert 0 = alles grün.
"""
from __future__ import annotations
import sys
from pathlib import Path
BACKEND = Path(__file__).resolve().parent
if str(BACKEND) not in sys.path:
sys.path.insert(0, str(BACKEND))
print("Pingognito-Selbsttest")
print("=" * 70)
# harness setzt PINGOGNITO_DATA_DIR vor allen App-Importen.
from selftest_suite import harness # noqa: E402, F401
from selftest_suite import test_core # noqa: E402, F401
from selftest_suite import test_workflow # noqa: E402, F401
from selftest_suite import test_rules_trend # noqa: E402, F401
from selftest_suite import test_auth_audit # noqa: E402, F401
from selftest_suite import test_infra_i18n # noqa: E402, F401
RESULTS = harness.RESULTS
bestanden = sum(1 for _, ok, _ in RESULTS if ok)
gesamt = len(RESULTS)
print("\n" + "=" * 70)
print(f"Ergebnis: {bestanden}/{gesamt} Tests bestanden")
if bestanden != gesamt:
print("\nFehlgeschlagen:")
for name, ok, detail in RESULTS:
if not ok:
print(f" - {name}: {detail}")
sys.exit(1)
print("Alle Tests grün.")
sys.exit(0)