Files
GlitchupBot/tests/test_config.py
Verum 2a7dfa95c8
Some checks failed
CI / Run tests (push) Has been cancelled
CI / Docker build test (push) Has been cancelled
CI / Lint (ruff + mypy) (push) Has been cancelled
initial commit
2026-03-30 16:46:26 +07:00

31 lines
1.4 KiB
Python

from glitchup_bot.config import get_settings
def test_settings_parse_lists_and_groups(monkeypatch):
monkeypatch.setenv("BACKEND_PROJECTS", "api-production,worker-production")
monkeypatch.setenv("FRONTEND_PROJECTS", "web-production")
monkeypatch.setenv("BACKEND_SUBSCRIBERS", "1,2")
monkeypatch.setenv("FRONTEND_SUBSCRIBERS", "7,8")
monkeypatch.setenv("TELEGRAM_ADMIN_IDS", "5,6")
monkeypatch.setenv("ALERT_ENVIRONMENTS", "production,hotfix")
monkeypatch.setenv("SYNC_INTERVAL_MINUTES", "45")
monkeypatch.setenv("ALERT_RATE_LIMIT_COUNT", "7")
monkeypatch.setenv("ALERT_RATE_LIMIT_WINDOW_MINUTES", "20")
settings = get_settings()
assert settings.backend_projects == ["api-production", "worker-production"]
assert settings.frontend_projects == ["web-production"]
assert settings.backend_subscribers == [1, 2]
assert settings.frontend_subscribers == [7, 8]
assert settings.telegram_admin_ids == [5, 6]
assert settings.alert_environments == ["production", "hotfix"]
assert settings.sync_interval_minutes == 45
assert settings.alert_rate_limit_count == 7
assert settings.alert_rate_limit_window_minutes == 20
assert settings.get_environment("api-production") == "production"
assert settings.get_group("web-production") == "frontend"
assert settings.get_group("unknown-project") == "backend"
assert settings.is_alert_environment("api-production") is True
assert settings.is_admin(5) is True