Files
awoooi/apps/api/tests/conftest.py
OG T 648e100e3c fix(tests): 修復測試 lint 錯誤 + TelegramGateway 方法呼叫
修復項目:
1. 新增 conftest.py 確保環境變數在 settings 前載入
2. test_github_webhook.py 移除重複的 os.environ 設定 (E402)
3. test_smart_router.py 排序 import (I001)
4. github_webhook.py 修正 send_message → send_notification

Phase 13.1 首席架構師審查修復

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-26 10:37:45 +08:00

26 lines
991 B
Python

"""
Test Configuration
==================
pytest conftest.py - 確保測試環境變數在所有模組載入前生效
Phase 13.1: GitHub Webhook 測試需要這些環境變數
"""
import os
# =============================================================================
# 關鍵: 在任何 import 之前設定環境變數
# =============================================================================
# pytest 會在所有 test_ 模組之前載入 conftest.py
# 這確保 settings singleton 建立時能讀到正確的測試值
os.environ.setdefault("MOCK_MODE", "true")
os.environ.setdefault("ENVIRONMENT", "dev")
os.environ.setdefault("GITHUB_WEBHOOK_SECRET", "test-secret-key-12345")
os.environ.setdefault("GITHUB_ALLOWED_REPOS", "test-owner/test-repo,wooo-ai/awoooi")
# =============================================================================
# Pytest Plugins
# =============================================================================
pytest_plugins = ["pytest_asyncio"]