add import audit trail, live indicator recompute, reportes endpoints; production hardening

This commit is contained in:
Roberto Treviño Cervantes
2026-10-30 11:19:30 -06:00
parent 168edb30f5
commit 2b2c290f58
74 changed files with 4095 additions and 1782 deletions
+4 -16
View File
@@ -13,7 +13,7 @@ import pytest
# Tests use throwaway SQLite files as "arbitrary SQL sources"; production
# excludes sqlite by default (see webapi.imports.connectors.sql_policy).
os.environ.setdefault("WEBAPI_SQL_ALLOWED_DIALECTS", "sqlite,mysql,mariadb,postgresql,mssql,oracle")
os.environ.setdefault("WEBAPI_SQL_ALLOWED_DIALECTS", "sqlite,mysql,mariadb,postgresql,mssql")
# The import log and the indicator queue write files; keep them out of the tree.
_STATE_DIR = tempfile.mkdtemp(prefix="webapi-tests-")
os.environ.setdefault("WEBAPI_REPORT_DIR", os.path.join(_STATE_DIR, "reportes"))
@@ -66,21 +66,9 @@ SEMESTRES = ["2025-S1", "2025-S2"]
MESES = ["2025-01", "2025-02", "2025-03"]
def sembrar_base(proyecto: str, motor) -> None:
"""La base de demostración del kit: staging sintético, carga y todos los indicadores calculados.
Lo mismo que hace `indicadores_kit.tea.fixtures.base_de_prueba` para
TEA: cada definición de `measures_de(proyecto)` queda calculada en los
periodos de 2025 que publica (`SEMESTRES`, y los doce meses si publica
meses).
"""
from indicadores_kit.demostracion import base_de_prueba
base_de_prueba(motor, proyecto)
def cliente_de(proyecto: str, tmp_path_factory):
"""Generador para la fixture `client` de un proyecto: una base SQLite temporal ya sembrada."""
"""Yields a client over a temporary SQLite database seeded with the kit's demonstration data."""
from indicadores_kit.demostracion import base_de_prueba
from persistance import db
from persistance.settings import settings
@@ -90,7 +78,7 @@ def cliente_de(proyecto: str, tmp_path_factory):
mp.setattr(settings, f"{proyecto}_database_url", f"sqlite:///{ruta}")
obtener_motor.cache_clear()
try:
sembrar_base(proyecto, obtener_motor())
base_de_prueba(obtener_motor(), proyecto)
from webapi import create_app