refactor: unify data preparations and research input snapshots
Deploy production / deploy (push) Successful in 53s
Deploy production / deploy (push) Successful in 53s
This commit is contained in:
@@ -10,11 +10,10 @@ from sqlalchemy import func, select
|
||||
from app.ai.capabilities import ToolContext, assemble
|
||||
from app.ai.tools import CAPABILITIES
|
||||
from app.business import Business
|
||||
from app.models import AIMessage, AIRun, AIToolCall, Alpha, Research, TemplateInput
|
||||
from app.models import AIMessage, AIRun, AIToolCall, Alpha, Research, ResearchInputSnapshot
|
||||
from app.research.service import ResearchBuilder
|
||||
from tests.test_ai import configure, single_tool_factory, start
|
||||
from tests.test_api import seed
|
||||
from tests.test_catalog import SCOPE
|
||||
from tests.test_catalog import catalog as catalog_fixture
|
||||
from tests.test_research_integration import fixed_input as fixed_input_fixture
|
||||
|
||||
@@ -62,15 +61,13 @@ async def test_prepare_failure_rolls_back_artifact_but_keeps_audit(app, logged_i
|
||||
# select_input has already persisted the new input before requesting its result page.
|
||||
raise HTTPException(422, "准备输入后的校验失败")
|
||||
|
||||
updated = await logged_in.patch(f"/api/v1/data-preparations/{fixed_input['preparation_id']}",
|
||||
json={"version": fixed_input["preparation_version"], "name": "new version"})
|
||||
assert updated.status_code == 200
|
||||
monkeypatch.setattr(ResearchBuilder, "input_page", unavailable_page)
|
||||
app.state.ai.model_factory = single_tool_factory(
|
||||
"prepare_research_input",
|
||||
{
|
||||
"scope": SCOPE,
|
||||
"dataset_id": "TEST_FIN",
|
||||
"collection_version": fixed_input["collection_version"],
|
||||
"field_ids": ["TEST_FIN_001"],
|
||||
},
|
||||
{"items": [{"id": fixed_input["preparation_id"], "version": updated.json()["version"]}]},
|
||||
)
|
||||
_, run, _ = await start(app, logged_in, "保存研究输入")
|
||||
call = run["tools"][0]
|
||||
@@ -78,7 +75,7 @@ async def test_prepare_failure_rolls_back_artifact_but_keeps_audit(app, logged_i
|
||||
assert call["presentation"]["effect"] == "prepare"
|
||||
assert call["result"]["error"] == "准备输入后的校验失败"
|
||||
async with app.state.sessions() as db:
|
||||
assert await db.scalar(select(func.count()).select_from(TemplateInput)) == 1
|
||||
assert await db.scalar(select(func.count()).select_from(ResearchInputSnapshot)) == 1
|
||||
assert (await db.get(AIToolCall, call["id"])).status == "failed"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user