85413bc1c6
- Create kb_pipeline package structure - Add test fixtures in conftest.py - Add 28 test cases for StepInput, StepOutput, StepStatus, StepRecord, WorkflowState - Add JSON serialization/deserialization tests - TDD RED phase: tests fail because schemas.py not yet implemented Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
60 lines
1.3 KiB
Python
60 lines
1.3 KiB
Python
"""Pytest 配置和共享 fixtures"""
|
|
|
|
import pytest
|
|
import tempfile
|
|
from pathlib import Path
|
|
from datetime import datetime
|
|
|
|
|
|
@pytest.fixture
|
|
def tmp_content_dir():
|
|
"""临时内容目录 fixture"""
|
|
with tempfile.TemporaryDirectory() as tmpdir:
|
|
yield Path(tmpdir)
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_step_input_data():
|
|
"""示例步骤输入数据"""
|
|
return {
|
|
"content_id": "BV1test123",
|
|
"platform": "bilibili"
|
|
}
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_step_output_data():
|
|
"""示例步骤输出数据"""
|
|
return {
|
|
"success": True,
|
|
"error_message": None,
|
|
"completed_at": datetime.now()
|
|
}
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_workflow_state_data():
|
|
"""示例工作流状态数据"""
|
|
return {
|
|
"schema_version": "1.0",
|
|
"content_id": "BV1test123",
|
|
"platform": "bilibili",
|
|
"source_url": "https://www.bilibili.com/video/BV1test123",
|
|
"created_at": datetime.now(),
|
|
"updated_at": datetime.now(),
|
|
"steps": {}
|
|
}
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_step_record_data():
|
|
"""示例步骤记录数据"""
|
|
return {
|
|
"step_name": "fetch_metadata",
|
|
"status": "completed",
|
|
"started_at": datetime.now(),
|
|
"completed_at": datetime.now(),
|
|
"error_message": None,
|
|
"output_summary": "成功获取元数据"
|
|
}
|