28 lines
1.1 KiB
Python
28 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
from ariadne import settings as settings_module
|
|
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
|
|
|
|
|
|
def test_from_env_includes_metis_settings(monkeypatch) -> None:
|
|
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")
|
|
monkeypatch.setenv("ARIADNE_SCHEDULE_METIS_SENTINEL_WATCH", "*/7 * * * *")
|
|
|
|
cfg = Settings.from_env()
|
|
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
|
|
assert cfg.metis_sentinel_watch_cron == "*/7 * * * *"
|