3.3 KiB
Raw Blame History

phase, plan, wave, title, depends_on, files_modified, autonomous, requirements
phase plan wave title depends_on files_modified autonomous requirements
6 1 1 三平台数据解析函数单元测试QUAL-02
tests/ingest/test_configs_boss.py
tests/ingest/test_configs_qcwy.py
tests/ingest/test_configs_zhilian.py
true
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.py8 个测试,覆盖 _extract_job_id_extract_company_name_build_boss_push
  • tests/ingest/test_configs_qcwy.py10 个测试,覆盖 _extract_job_id_extract_update_dt_extract_company_name_build_qcwy_push(含 welfare 列表场景)
  • tests/ingest/test_configs_zhilian.py9 个测试,覆盖 _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

# 运行新测试
pipenv run python -m pytest tests/ingest/ -v --tb=short

# 全量回归
pipenv run python -m pytest tests/ -v --tb=short

预期: 所有 27-30 个测试通过,全量 ≥ 130 个测试全绿