"""
测试包初始化文件
提供测试的公共配置、工具函数和fixture
"""
import pytest
import tempfile
from pathlib import Path
from typing import Generator
from decimal import Decimal
from datetime import date
@pytest.fixture
def tmp_data_dir() -> Generator[Path, None, None]:
"""临时数据目录fixture"""
with tempfile.TemporaryDirectory() as tmp_dir:
yield Path(tmp_dir)
@pytest.fixture
def sample_transaction_data() -> dict:
"""示例交易数据"""
return {
"id": "txn_20250115_001",
"amount": -50.00,
"category": "food",
"description": "午餐",
"date": "2025-01-15",
"timestamp": "2025-01-15T12:30:00Z"
}
@pytest.fixture
def sample_account_data() -> dict:
"""示例账户数据"""
return {
"balance": -50.00,
"total_transactions": 1,
"created_at": "2025-01-15T00:00:00Z",
"last_updated": "2025-01-15T12:30:00Z"
}
@pytest.fixture
def sample_categories_data() -> list:
"""示例分类数据"""
return [
{
"id": "food",
"name": "餐饮",
"description": "餐费、外卖等",
"type": "expense",
"color": "#FF6B6B",
"icon": "🍽️"
},
{
"id": "income",
"name": "收入",
"description": "工资、奖金等",
"type": "income",
"color": "#90EE90",
"icon": "💰"
}
]