Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5349997586 |
No files matched your search
+4
-1
@@ -13,7 +13,10 @@ from app.models import Base
|
||||
|
||||
config = context.config
|
||||
if config.config_file_name is not None:
|
||||
fileConfig(config.config_file_name)
|
||||
# Sin deshabilitar los loggers que ya existen: si no, una migración dentro de la suite apaga
|
||||
# los de la aplicación (p. ej. `app.services.alertas`) y las pruebas que leen el log fallan
|
||||
# según el orden en que corren (backlog O13).
|
||||
fileConfig(config.config_file_name, disable_existing_loggers=False)
|
||||
|
||||
# Una URL fijada por código (tests) gana sobre DATABASE_URL del entorno.
|
||||
if not config.get_main_option("sqlalchemy.url"):
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
"""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
|
||||
Reference in new issue
Block a user