ae1ee4633f
Orquestacion was a separate uv package with exactly one consumer (webapi.indicadores_vivos) and no independent deployment: the Dockerfile already copied it straight into this image and ran one uv sync for everything. Folding it in removes a redundant pyproject.toml/uv.lock/venv without losing the standalone CLI (python -m webapi.orquestacion ciclo/ confirmar-riesgos) or its test suite, which now runs as part of this project's own pytest run. 417 tests pass (416 unchanged + the merged orquestacion suite); verified live in a built image, where the indicadores worker completed a full cacu/cama/tea cycle against webapi.orquestacion.ejecutor.
32 lines
1.5 KiB
Python
32 lines
1.5 KiB
Python
"""La regla de §6 (`arquitectura_grafo_etl.md`): ningún paso abre una sesión; todo va por `ctx.repos`.
|
|
|
|
Las subclases viven en `persistance/aristas/` y Persistance las instancia con su
|
|
fábrica de sesión (ADR-MD-005). Solo `conexion.py` nombra a `persistance.db`: cambia a
|
|
qué base apunta Persistance (`<PROYECTO>_DATABASE_URL` en memoria); no es un paso. Esta prueba es la comprobación de
|
|
`_docs/medallon/README.md`, «Reglas de cada paso».
|
|
"""
|
|
|
|
import re
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from webapi.orquestacion.repositorios import repositorios_de
|
|
|
|
PAQUETE = Path(__file__).parents[1] / "webapi" / "orquestacion"
|
|
EXENTOS = {"conexion.py"}
|
|
PROHIBIDO = re.compile(r"fabrica_por_defecto|get_(cacu|cama|tea)_session|get_\{|Session\(|persistance\.db")
|
|
|
|
|
|
@pytest.mark.parametrize("modulo", sorted(str(p.relative_to(PAQUETE)) for p in PAQUETE.rglob("*.py") if p.name not in EXENTOS and ".ipynb_checkpoints" not in p.parts))
|
|
def test_ningun_modulo_fuera_de_repositorios_abre_sesiones(modulo):
|
|
texto = (PAQUETE / modulo).read_text(encoding="utf-8")
|
|
assert not PROHIBIDO.findall(texto), f"{modulo} abre su propia sesión: debe usar ctx.repos"
|
|
|
|
|
|
@pytest.mark.parametrize("proyecto, con_cohortes", [("cacu", True), ("cama", True), ("tea", True)])
|
|
def test_cada_proyecto_tiene_sus_repositorios(proyecto, con_cohortes):
|
|
repos = repositorios_de(proyecto)
|
|
assert (repos.oro.cohorte is not None) == con_cohortes
|
|
assert repos.oro.calculo.model.__tablename__ == "measure_report"
|