""" 整合測試配置 提供 FastAPI 測試客戶端和通用 fixtures """ import pytest import pytest_asyncio from httpx import AsyncClient, ASGITransport from backend.main import app @pytest_asyncio.fixture async def client(): """ AsyncClient fixture for testing FastAPI endpoints 使用 httpx.AsyncClient 來測試 async 端點 """ transport = ASGITransport(app=app) async with AsyncClient(transport=transport, base_url="http://test") as ac: yield ac @pytest.fixture def sample_csv_content(): """範例 CSV 內容""" return b"""id,title,start,end,group,description,color evt-001,Event 1,2024-01-01,2024-01-02,Group A,Test event 1,#3B82F6 evt-002,Event 2,2024-01-05,2024-01-06,Group B,Test event 2,#10B981 evt-003,Event 3,2024-01-10,,Group A,Test event 3,#F59E0B """