ariadne/testing/test_settings.py

28 lines
1.1 KiB
Python
Raw Normal View History

from __future__ import annotations
from ariadne import settings as settings_module
2026-03-31 14:07:02 -03:00
from ariadne.settings import Settings
def test_env_int_invalid(monkeypatch) -> None:
monkeypatch.setenv("ARIADNE_INT_TEST", "bad")
assert settings_module._env_int("ARIADNE_INT_TEST", 5) == 5
def test_env_float_invalid(monkeypatch) -> None:
monkeypatch.setenv("ARIADNE_FLOAT_TEST", "bad")
assert settings_module._env_float("ARIADNE_FLOAT_TEST", 1.5) == 1.5
2026-03-31 14:07:02 -03:00
def test_from_env_includes_metis_settings(monkeypatch) -> None:
2026-03-31 14:18:31 -03:00
monkeypatch.setenv("METIS_BASE_URL", "http://metis.maintenance.svc.cluster.local/")
monkeypatch.setenv("METIS_WATCH_URL", "http://metis.example/internal/sentinel/watch")
monkeypatch.setenv("METIS_TIMEOUT_SEC", "9.5")
2026-03-31 14:07:02 -03:00
monkeypatch.setenv("ARIADNE_SCHEDULE_METIS_SENTINEL_WATCH", "*/7 * * * *")
cfg = Settings.from_env()
2026-03-31 14:18:31 -03:00
assert cfg.metis_base_url == "http://metis.maintenance.svc.cluster.local"
assert cfg.metis_watch_url == "http://metis.example/internal/sentinel/watch"
assert cfg.metis_timeout_sec == 9.5
2026-03-31 14:07:02 -03:00
assert cfg.metis_sentinel_watch_cron == "*/7 * * * *"