149 lines
4.2 KiB
Markdown
149 lines
4.2 KiB
Markdown
---
|
||
phase: 09-pipeline-integration
|
||
plan: 00
|
||
type: execute
|
||
wave: 0
|
||
depends_on: []
|
||
files_modified: []
|
||
autonomous: true
|
||
requirements: []
|
||
user_setup: []
|
||
|
||
must_haves:
|
||
truths:
|
||
- "测试脚手架已就绪,为 Wave 1 实现提供验证基础"
|
||
artifacts:
|
||
- path: "tests/test_platforms/test_zhihu.py"
|
||
provides: "Test scaffolding for ZhihuAdapter"
|
||
min_lines: 30
|
||
exports: ["mock_zhihu_answer_result", "mock_zhihu_zhuanlan_result"]
|
||
key_links: []
|
||
---
|
||
|
||
<objective>
|
||
创建 Wave 0 测试脚手架,为后续实现任务提供验证基础。
|
||
|
||
Purpose: 遵循 Nyquist 规则,测试先于实现,确保每个实现任务有对应的自动化验证
|
||
Output: 测试文件骨架和 mock fixtures
|
||
</objective>
|
||
|
||
<execution_context>
|
||
@/home/starmen1265/.claude/get-shit-done/workflows/execute-plan.md
|
||
@/home/starmen1265/.claude/get-shit-done/templates/summary.md
|
||
</execution_context>
|
||
|
||
<context>
|
||
@.planning/PROJECT.md
|
||
@.planning/ROADMAP.md
|
||
@.planning/STATE.md
|
||
@.planning/phases/09-pipeline-integration/09-CONTEXT.md
|
||
|
||
<interfaces>
|
||
From kb_workflow/crawler/models.py:
|
||
```python
|
||
class CrawlResult(BaseModel):
|
||
success: bool
|
||
content_type: str
|
||
data: Optional[Union[AnswerData, ArticleData]]
|
||
comments: Optional[List[CommentData]]
|
||
error: Optional[str]
|
||
|
||
class AnswerData(BaseModel):
|
||
question_title: str
|
||
question_description: Optional[str]
|
||
answer_content: str
|
||
author: AuthorInfo
|
||
voteup_count: int
|
||
comment_count: int
|
||
created_time: int
|
||
updated_time: Optional[int]
|
||
|
||
class ArticleData(BaseModel):
|
||
title: str
|
||
content: str
|
||
author: AuthorInfo
|
||
voteup_count: int
|
||
comment_count: int
|
||
created_time: int
|
||
updated_time: Optional[int]
|
||
|
||
class CommentData(BaseModel):
|
||
id: int
|
||
content: str
|
||
author: CommentAuthor
|
||
vote_count: int
|
||
created_time: int
|
||
```
|
||
|
||
From kb_workflow/auth/zhihu_login.py:
|
||
```python
|
||
class ZhihuLoginResult(BaseModel):
|
||
success: bool
|
||
cookie_str: Optional[str]
|
||
error: Optional[str]
|
||
|
||
class CookieValidationResult(BaseModel):
|
||
valid: bool
|
||
user_id: Optional[str]
|
||
error: Optional[str]
|
||
```
|
||
</interfaces>
|
||
</context>
|
||
|
||
<tasks>
|
||
|
||
<task type="auto">
|
||
<name>Task 0: Create test scaffolding and mock fixtures</name>
|
||
<files>tests/test_platforms/test_zhihu.py</files>
|
||
<action>
|
||
创建测试文件骨架,包含以下内容:
|
||
|
||
1. Mock fixtures:
|
||
- `mock_zhihu_answer_result`: 模拟 ZhihuCrawler.crawl_answer() 返回的 CrawlResult
|
||
- `mock_zhihu_zhuanlan_result`: 模拟 ZhihuCrawler.crawl_article() 返回的 CrawlResult
|
||
- `mock_comments_list`: 模拟评论列表数据
|
||
- `mock_zhihu_login_result`: 模拟 ZhihuLogin.login_by_qrcode() 返回结果
|
||
|
||
2. 测试用例骨架(使用 pytest.mark.skip 标记,等待实现后移除):
|
||
- `test_fetch_metadata_answer`: 测试问答元数据获取
|
||
- `test_fetch_metadata_article`: 测试专栏文章元数据获取
|
||
- `test_fetch_content_with_comments`: 测试带评论的内容获取
|
||
- `test_cookie_expired_triggers_login`: 测试 Cookie 过期触发登录
|
||
- `test_idempotent_execution`: 测试幂等执行
|
||
- `test_comment_formatting`: 测试评论格式化
|
||
|
||
3. Mock 配置:
|
||
- 使用 pytest-mock 或 unittest.mock
|
||
- 配置 ZhihuCrawler mock 返回预期的 CrawlResult
|
||
- 配置 ZhihuLogin mock 返回预期的登录结果
|
||
|
||
文件末尾添加注释标记:
|
||
```python
|
||
# WAVE_0_COMPLETE: Test scaffolding ready for implementation
|
||
```
|
||
</action>
|
||
<verify>
|
||
<automated>pytest tests/test_platforms/test_zhihu.py --collect-only -q 2>&1 | grep -c "test_"</automated>
|
||
</verify>
|
||
<done>
|
||
测试文件存在,包含至少 6 个测试用例骨架和 4 个 mock fixtures
|
||
</done>
|
||
</task>
|
||
|
||
</tasks>
|
||
|
||
<verification>
|
||
测试骨架已创建,测试可以被 pytest 收集(即使被 skip)
|
||
</verification>
|
||
|
||
<success_criteria>
|
||
- tests/test_platforms/test_zhihu.py 文件存在
|
||
- 包含 mock fixtures: mock_zhihu_answer_result, mock_zhihu_zhuanlan_result, mock_comments_list, mock_zhihu_login_result
|
||
- 包含测试骨架: test_fetch_metadata_answer, test_fetch_metadata_article, test_fetch_content_with_comments, test_cookie_expired_triggers_login, test_idempotent_execution, test_comment_formatting
|
||
- pytest 可以收集到所有测试用例
|
||
</success_criteria>
|
||
|
||
<output>
|
||
After completion, create `.planning/phases/09-pipeline-integration/09-00-SUMMARY.md`
|
||
</output>
|