Files
resume-agent/backend/tests/builder_flow_helpers.py
T
hypandClaude ae2d9b128d feat: builder 简历生成 + 轻度优化 + 简历导入交付副本
自内部仓库剥离深度优化与 RAG 知识库后的交付版本:
- Builder 对话式简历生成(FSM + 意图路由 LLM 兜底增强)
- 条目级轻度优化:事实覆盖门禁 + STAR/bullet 修复链,功能/简介/成果与技术栈同级保护
- 简历导入:DOCX/PDF 解析、结构归一、手机号脱敏
- PostgreSQL 运行时 + Alembic 迁移链

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-05 11:08:30 +08:00

66 lines
2.6 KiB
Python

"""Shared helpers for Builder conversation tests."""
from __future__ import annotations
from typing import Any
from fastapi.testclient import TestClient
from test_api import BASE, active_component, event, start_manual_profile # noqa: F401
EDUCATION_IDENTITY = {
"school": "Example University",
"major": "Computer Science",
"degree": "Bachelor",
"start_date": "2021-09",
"end_date_or_present": "2025-06",
}
def create_builder_session(client: TestClient, *, job_type: str = "campus") -> tuple[str, dict[str, Any]]:
session_id, _ = start_manual_profile(client, job_type=job_type)
created = client.post(f"{BASE}/sessions/{session_id}/create", json={})
assert created.status_code == 200, created.text
body = created.json()
assert body["stage"] == "BUILDER_CONVERSATION"
return session_id, body
def select_section(client: TestClient, session_id: str, body: dict[str, Any], section: str) -> dict[str, Any]:
response = event(client, session_id, body, "select", {"value": section})
assert response.status_code == 200, response.text
return response.json()
def submit_identity(client: TestClient, session_id: str, body: dict[str, Any], values: dict[str, str]) -> dict[str, Any]:
response = event(client, session_id, body, "submit", values)
assert response.status_code == 200, response.text
return response.json()
def send_message(client: TestClient, session_id: str, content: str) -> dict[str, Any]:
response = client.post(f"{BASE}/sessions/{session_id}/messages", json={"content": content})
assert response.status_code == 200, response.text
return response.json()
def confirm_card(client: TestClient, session_id: str, body: dict[str, Any], *, use_optimized: bool = False) -> dict[str, Any]:
response = event(client, session_id, body, "confirm", {"use_optimized": use_optimized})
assert response.status_code == 200, response.text
return response.json()
def start_education(client: TestClient, session_id: str, body: dict[str, Any], *, school: str = "Example University") -> dict[str, Any]:
card = select_section(client, session_id, body, "education")
identity = {**EDUCATION_IDENTITY, "school": school}
prompt = submit_identity(client, session_id, card, identity)
assert "没有也可以直接说没有" in prompt["turn"]["content"]
return prompt
def finish_education(client: TestClient, session_id: str, body: dict[str, Any], detail: str) -> dict[str, Any]:
proposal = send_message(client, session_id, detail)
assert active_component(proposal)["data"]["component"] == "experience_confirm_card"
return proposal