93 lines
3.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
phase: 6
plan: 1
wave: 1
title: "三平台数据解析函数单元测试QUAL-02"
depends_on: []
files_modified:
- tests/ingest/test_configs_boss.py # NEW
- tests/ingest/test_configs_qcwy.py # NEW
- tests/ingest/test_configs_zhilian.py # NEW
autonomous: true
requirements:
- QUAL-02
---
# Phase 6 Plan 01: 三平台解析函数单元测试QUAL-02
## Objective
`app/services/ingest/configs/` 中的三平台 `_extract_*``_build_*_push` 函数
新增单元测试,覆盖正常字段和缺字段场景。
去重逻辑测试dedup.py已在 Phase 5 完成6 个测试),本 Plan 仅补充解析函数测试。
## Must Haves
- [ ] `tests/ingest/test_configs_boss.py`8 个测试,覆盖 `_extract_job_id``_extract_company_name``_build_boss_push`
- [ ] `tests/ingest/test_configs_qcwy.py`10 个测试,覆盖 `_extract_job_id``_extract_update_dt``_extract_company_name``_build_qcwy_push`(含 welfare 列表场景)
- [ ] `tests/ingest/test_configs_zhilian.py`9 个测试,覆盖 `_extract_number``_extract_fpt``_extract_company_name``_build_zhilian_push`
- [ ] `pipenv run python -m pytest tests/ingest/ -v --tb=short` 全部绿色(含原有 dedup 6 个)
- [ ] `pipenv run python -m pytest tests/ -v` 全量通过
---
## Wave 1
### Task 1.1: tests/ingest/test_configs_boss.py
**测试清单:**
1. `test_extract_job_id_from_jobBaseInfoVO` — 正常嵌套字段
2. `test_extract_job_id_missing` — 缺 jobBaseInfoVO → None
3. `test_extract_company_name_from_name` — data["name"] 直接取
4. `test_extract_company_name_from_companyFullInfoVO` — 嵌套字段
5. `test_extract_company_name_missing` → None
6. `test_build_boss_push_full` — 完整字段,验证 source_type="Boss直聘"、url 含 encryptJobId
7. `test_build_boss_push_partial` — 缺字段不 raise返回合理降级值
8. `test_build_boss_push_none_data` — 空 dict关键字段为 None
---
### Task 1.2: tests/ingest/test_configs_qcwy.py
**测试清单:**
1. `test_extract_job_id_normal`
2. `test_extract_job_id_missing` → None
3. `test_extract_update_dt_normal`
4. `test_extract_update_dt_missing` → None
5. `test_extract_company_name_from_companyName`
6. `test_extract_company_name_from_company_name_fallback`
7. `test_extract_company_name_missing` → None
8. `test_build_qcwy_push_welfare_list` — welfare 为对象列表,提取 chineseTitle
9. `test_build_qcwy_push_welfare_string` — welfare 为字符串
10. `test_build_qcwy_push_partial` — 缺字段 → 合理降级source_type="前程无忧"
---
### Task 1.3: tests/ingest/test_configs_zhilian.py
**测试清单:**
1. `test_extract_number_normal`
2. `test_extract_number_missing` → None
3. `test_extract_fpt_normal`
4. `test_extract_fpt_missing` → None
5. `test_extract_company_name_from_companyName`
6. `test_extract_company_name_from_name_fallback`
7. `test_extract_company_name_missing` → None
8. `test_build_zhilian_push_skill_labels` — skillLabel 列表,提取 value
9. `test_build_zhilian_push_partial` — 缺字段降级source_type="智联招聘"
---
## Verification
```bash
# 运行新测试
pipenv run python -m pytest tests/ingest/ -v --tb=short
# 全量回归
pipenv run python -m pytest tests/ -v --tb=short
```
**预期:** 所有 27-30 个测试通过,全量 ≥ 130 个测试全绿