"""Revise action on the confirm card: fold uncovered facts back into the proposal (问题2c).""" from __future__ import annotations from typing import Any from builder_flow_helpers import create_builder_session, event, finish_education, start_education from test_api import active_component def _revise(client: Any, session_id: str, body: dict[str, Any], payload: dict[str, Any]) -> Any: return event(client, session_id, body, "revise", payload) def test_revise_regenerates_proposal_with_instruction(client: Any) -> None: session_id, body = create_builder_session(client) card = start_education(client, session_id, body) proposal = finish_education(client, session_id, card, "完成数据库课程项目。GPA: 4.3/5.0。") response = _revise( client, session_id, proposal, {"instruction": "请将以下未覆盖的事实补进优化稿:GPA: 4.3/5.0,其他内容保持不变。"}, ) assert response.status_code == 200, response.text reply = response.json() assert active_component(reply)["data"]["component"] == "experience_confirm_card" assert "重新" in reply["turn"]["content"] proposal_data = active_component(reply)["data"]["ai_proposal"] assert proposal_data["optimized_description"] def test_revise_without_instruction_rejected(client: Any) -> None: session_id, body = create_builder_session(client) card = start_education(client, session_id, body) proposal = finish_education(client, session_id, card, "完成数据库课程项目。GPA: 4.3/5.0。") response = _revise(client, session_id, proposal, {}) assert response.status_code == 422, response.text def test_revise_without_pending_proposal_rejected(client: Any) -> None: session_id, body = create_builder_session(client) response = _revise(client, session_id, body, {"instruction": "重新优化"}) assert response.status_code in (404, 409, 422), response.text