Spaces:
Runtime error
Runtime error
Download tests/test_config.py from MateFerreyra/Modulo-6: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/spaces/MateFerreyra/Modulo-6/resolve/main/tests/test_config.py
- Command line
-
hf download hf://spaces/MateFerreyra/Modulo-6/tests/test_config.py
-
curl -L -o test_config.py https://huggingface.co/spaces/MateFerreyra/Modulo-6/resolve/main/tests/test_config.py
1.53 kB
| """ | |
| Tests de `app/config.py::Settings._blank_non_str_env_vars_fall_back_to_default`. | |
| Contexto real: dos incidentes en producción (HF Spaces) donde una env var declarada | |
| pero vacía tiró abajo el arranque entero de la app (`ValidationError` en `Settings()`, | |
| antes de que `main.py` llegue a levantar cualquier endpoint) — primero con los | |
| `*_event_type_id`, después con `RABBITMQ_PORT`/`RABBITMQ_CONSUMER_ENABLED`. | |
| """ | |
| from app.config import Settings | |
| _REQUIRED = {"supabase_url": "https://x.supabase.co", "supabase_key": "x", "jwt_secret": "x"} | |
| def test_int_vacio_cae_al_default(): | |
| s = Settings(**_REQUIRED, rabbitmq_port="") | |
| assert s.rabbitmq_port == 5672 | |
| def test_bool_vacio_cae_al_default(): | |
| s = Settings(**_REQUIRED, rabbitmq_consumer_enabled="") | |
| assert s.rabbitmq_consumer_enabled is False | |
| def test_int_or_none_vacio_cae_a_none(): | |
| s = Settings(**_REQUIRED, facturacion_cama_lista_event_type_id="") | |
| assert s.facturacion_cama_lista_event_type_id is None | |
| def test_str_vacio_se_conserva_tal_cual(): | |
| """Para campos str, "" ya es la semántica normal de "no configurado" — no tocar.""" | |
| s = Settings(**_REQUIRED, core_service_email="") | |
| assert s.core_service_email == "" | |
| def test_int_con_valor_real_no_se_toca(): | |
| s = Settings(**_REQUIRED, rabbitmq_port="6672") | |
| assert s.rabbitmq_port == 6672 | |
| def test_int_or_none_con_valor_real_no_se_toca(): | |
| s = Settings(**_REQUIRED, facturacion_cama_lista_event_type_id="19") | |
| assert s.facturacion_cama_lista_event_type_id == 19 | |