initial commit
This commit is contained in:
30
tests/test_config.py
Normal file
30
tests/test_config.py
Normal file
@@ -0,0 +1,30 @@
|
||||
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
|
||||
Reference in New Issue
Block a user