conftest.py•2.11 kB
"""
pytest設定ファイル
共通のフィクスチャや設定を定義
"""
import pytest
import sys
import os
from pathlib import Path
# プロジェクトルートをPythonパスに追加
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root / "src"))
# テストモードの設定
USE_REAL_API = os.getenv('USE_REAL_API', 'false').lower() in ('true', '1', 'yes')
@pytest.fixture
def mock_google_service():
"""
Google APIサービスのモックフィクスチャ
"""
with pytest.mock.patch('src.tools.calendar_tools.get_service') as mock_service:
yield mock_service
@pytest.fixture
def sample_calendar_data():
"""
テスト用のサンプルカレンダーデータ
"""
return {
'items': [
{
'id': 'primary',
'summary': 'Primary Calendar',
'description': 'Main calendar',
'timeZone': 'Asia/Tokyo',
'accessRole': 'owner'
},
{
'id': 'secondary@example.com',
'summary': 'Secondary Calendar',
'description': 'Work calendar',
'timeZone': 'UTC',
'accessRole': 'reader'
}
]
}
@pytest.fixture
def sample_event_data():
"""
テスト用のサンプルイベントデータ
"""
return {
'items': [
{
'id': 'event1',
'summary': 'Test Meeting',
'description': 'Test meeting description',
'start': {'dateTime': '2024-01-01T09:00:00Z'},
'end': {'dateTime': '2024-01-01T10:00:00Z'},
'location': 'Test Location',
'attendees': [
{'email': 'user1@example.com'},
{'email': 'user2@example.com'}
]
},
{
'id': 'event2',
'summary': 'All Day Event',
'start': {'date': '2024-01-02'},
'end': {'date': '2024-01-03'}
}
]
}