27 lines
960 B
Python
27 lines
960 B
Python
"""Correr una migración no apaga los loggers de la aplicación (backlog O13).
|
|
|
|
`alembic/env.py` configura el logging con `alembic.ini`; con `disable_existing_loggers=True` (el
|
|
valor por omisión de `fileConfig`) deshabilitaba `app.services.alertas`, y la prueba que lee su
|
|
advertencia fallaba si corría después de una prueba de migración.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
from pathlib import Path
|
|
|
|
from alembic import command
|
|
from alembic.config import Config
|
|
|
|
RAIZ = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def test_una_migracion_no_deshabilita_los_loggers_de_la_app(tmp_path: Path) -> None:
|
|
logger = logging.getLogger("app.services.alertas")
|
|
assert not logger.disabled
|
|
cfg = Config(str(RAIZ / "alembic.ini"))
|
|
cfg.set_main_option("script_location", str(RAIZ / "alembic"))
|
|
cfg.set_main_option("sqlalchemy.url", f"sqlite:///{tmp_path / 'logging.db'}")
|
|
command.upgrade(cfg, "0001")
|
|
assert not logger.disabled
|