- 新增 Redis 表級快取機制,減少 Oracle 查詢負載 - 實作 CacheUpdater 背景任務,每 10 分鐘檢查 SYS_DATE 並更新快取 - 所有 WIP API 端點改為 cache-first + Oracle fallback 架構 - 新增 /health 端點顯示資料庫、Redis、快取狀態 - 前端 Portal 新增即時健康狀態指示器 - SQLAlchemy 連線設置 call_timeout=55s 防止 Worker 卡死 - Gunicorn 加入 max_requests=1000 確保 Worker 定期重啟 - 完整測試覆蓋:67 項單元/整合/E2E 測試 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
51 lines
1.3 KiB
Python
51 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Pytest configuration for Playwright E2E tests."""
|
|
|
|
import pytest
|
|
import os
|
|
import sys
|
|
|
|
# Add src to path
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', 'src'))
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def app_server() -> str:
|
|
"""Get the base URL for E2E testing.
|
|
|
|
Uses environment variable E2E_BASE_URL or defaults to production server.
|
|
"""
|
|
return os.environ.get('E2E_BASE_URL', 'http://127.0.0.1:8080')
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def browser_context_args(browser_context_args):
|
|
"""Configure browser context for tests."""
|
|
return {
|
|
**browser_context_args,
|
|
"viewport": {"width": 1280, "height": 720},
|
|
"locale": "zh-TW",
|
|
}
|
|
|
|
|
|
def pytest_configure(config):
|
|
"""Add custom markers for E2E tests."""
|
|
config.addinivalue_line(
|
|
"markers", "e2e: mark test as end-to-end test (requires running server)"
|
|
)
|
|
config.addinivalue_line(
|
|
"markers", "redis: mark test as requiring Redis connection"
|
|
)
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def api_base_url(app_server):
|
|
"""Get the API base URL."""
|
|
return f"{app_server}/api"
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def health_url(app_server):
|
|
"""Get the health check URL."""
|
|
return f"{app_server}/health"
|