2026-10-15 00:14:41 -05:00
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
2026-10-19 23:15:23 -05:00
|
|
|
import database_utilities
|
|
|
|
|
|
2026-10-15 00:14:41 -05:00
|
|
|
RAIZ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
|
FIXTURES = os.path.join(RAIZ, "tests", "fixtures", "correos_prueba")
|
|
|
|
|
GOLDEN = os.path.join(RAIZ, "tests", "golden")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def actualizar_golden() -> bool:
|
|
|
|
|
"""True si se ejecutó con ``UPDATE_GOLDEN=1`` (regenera los resultados esperados)."""
|
|
|
|
|
return os.environ.get("UPDATE_GOLDEN") == "1"
|
2026-10-19 23:15:23 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
|
|
|
def base_de_datos_temporal(tmp_path_factory, monkeypatch):
|
|
|
|
|
"""
|
|
|
|
|
Toda prueba usa una BD SQLite propia: ``DB_NAME`` es relativo al directorio
|
|
|
|
|
de trabajo, así que sin esto se escribiría en el ``emails.db`` real.
|
|
|
|
|
"""
|
|
|
|
|
monkeypatch.setattr(database_utilities, "DB_NAME", str(tmp_path_factory.mktemp("bd") / "emails_prueba.db"))
|
|
|
|
|
database_utilities.init_db()
|
2026-10-22 08:55:54 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
|
|
|
def entorno_de_notificacion_aislado(monkeypatch):
|
|
|
|
|
"""
|
|
|
|
|
Los módulos cargan el ``.env`` real al importarse. Las pruebas no deben depender de él:
|
|
|
|
|
sin esto, un ``NOTIFICACION_MODO=real`` del .env haría que se probara (y enviara) en modo real.
|
|
|
|
|
"""
|
|
|
|
|
for variable in ("NOTIFICACION_MODO", "NOTIFICACION_EQUIPO", "NOTIFICACION_CONTACTO", "LOGO_URL"):
|
|
|
|
|
monkeypatch.delenv(variable, raising=False)
|
|
|
|
|
monkeypatch.setenv("EMAIL", "buzon@aberio.com")
|