initial commit
This commit is contained in:
46
tests/conftest.py
Normal file
46
tests/conftest.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from glitchup_bot.config import clear_settings_cache
|
||||
|
||||
DEFAULT_ENV = {
|
||||
"TELEGRAM_BOT_TOKEN": "token",
|
||||
"TELEGRAM_GROUP_CHAT_ID": "-1001234567890",
|
||||
"TELEGRAM_BACKEND_TOPIC_ID": "11",
|
||||
"TELEGRAM_FRONTEND_TOPIC_ID": "22",
|
||||
"TELEGRAM_DIGEST_TOPIC_ID": "33",
|
||||
"BACKEND_PROJECTS": "backend-production,backend-staging",
|
||||
"FRONTEND_PROJECTS": "frontend-production,frontend-staging",
|
||||
"BACKEND_SUBSCRIBERS": "",
|
||||
"FRONTEND_SUBSCRIBERS": "",
|
||||
"TELEGRAM_ADMIN_IDS": "",
|
||||
"GLITCHTIP_URL": "https://glitchtip.example.com",
|
||||
"GLITCHTIP_API_TOKEN": "secret",
|
||||
"GLITCHTIP_ORG_SLUG": "org",
|
||||
"DATABASE_URL": "postgresql+asyncpg://glitchup:glitchup@db:5432/glitchup",
|
||||
"API_PORT": "8080",
|
||||
"WEBHOOK_SECRET": "",
|
||||
"DIGEST_CRON_DAY": "mon",
|
||||
"DIGEST_CRON_HOUR": "10",
|
||||
"DIGEST_CRON_MINUTE": "0",
|
||||
"DIGEST_TIMEZONE": "Asia/Krasnoyarsk",
|
||||
"SYNC_INTERVAL_MINUTES": "30",
|
||||
"ALERT_ENVIRONMENTS": "production",
|
||||
"DEDUP_WINDOW_HOURS": "6",
|
||||
"ALERT_RATE_LIMIT_COUNT": "10",
|
||||
"ALERT_RATE_LIMIT_WINDOW_MINUTES": "15",
|
||||
}
|
||||
|
||||
for key, value in DEFAULT_ENV.items():
|
||||
os.environ.setdefault(key, value)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def reset_settings(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
for key, value in DEFAULT_ENV.items():
|
||||
monkeypatch.setenv(key, value)
|
||||
|
||||
clear_settings_cache()
|
||||
yield
|
||||
clear_settings_cache()
|
||||
Reference in New Issue
Block a user