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:
@@ -162,7 +162,8 @@ async def test_official_sdk_client_and_error_contract(mcp_app):
|
||||
async with ClientSession(streams[0], streams[1]) as client:
|
||||
await client.initialize()
|
||||
listed = await client.list_tools()
|
||||
assert len(listed.tools) == 18
|
||||
assert len(listed.tools) == 20
|
||||
assert {"search_data_preparations", "get_data_preparation"} <= {t.name for t in listed.tools}
|
||||
caps = await client.call_tool("get_research_capabilities", {})
|
||||
assert caps.structured_content["max_candidates"] == 100
|
||||
result = await client.call_tool("submit_backtests", submission())
|
||||
@@ -459,3 +460,27 @@ async def test_worldquant_authentication_permissions_and_challenge(mcp_app):
|
||||
assert missing.structured_content["error"]["code"] == "CREDENTIALS_NOT_CONFIGURED"
|
||||
wrong = await mcp_app.state.mcp.invoke(principal, "get_worldquant_connection", {"job_id": "unrelated"})
|
||||
assert wrong.structured_content["error"]["code"] == "NOT_FOUND"
|
||||
|
||||
async def test_mcp_preparations_freeze_at_submit_and_survive_deletion(mcp_app):
|
||||
from app.catalog.contracts import Scope
|
||||
from app.preparations.contracts import PreparationReference
|
||||
from app.preparations.service import Preparations
|
||||
principal, _ = await credentials(mcp_app)
|
||||
async with mcp_app.state.sessions.begin() as db:
|
||||
collection = await Preparations(db).create("MCP prepared", "", Scope(region="USA", universe="TOP3000", delay=1),
|
||||
[{"id": "close", "field_id": "close", "name": "Close", "dataset_id": "pv1", "dataset_name": "Price",
|
||||
"description": "Synthetic close", "field_type": "MATRIX", "source": "local", "fetched_at": now().isoformat()}])
|
||||
refs = [{"id": collection["id"], "version": 1}]
|
||||
found = await invoke(mcp_app, principal, "search_data_preparations", {"q": "MCP prepared"})
|
||||
assert found["items"][0]["id"] == collection["id"]
|
||||
detail = await invoke(mcp_app, principal, "get_data_preparation", {**refs[0], "limit": 1})
|
||||
assert detail["fields"]["items"][0]["dataset_id"] == "pv1"
|
||||
result = await invoke(mcp_app, principal, "submit_backtests", submission(preparation_refs=refs))
|
||||
async with mcp_app.state.sessions.begin() as db:
|
||||
run = await db.get(BacktestRun, result["backtest_run_id"])
|
||||
snapshot_id = run.source["input_snapshot_ids"][0]
|
||||
await Preparations(db).remove([PreparationReference(**refs[0])])
|
||||
assert (await Preparations(db).snapshot(snapshot_id))["fields"][0]["description"] == "Synthetic close"
|
||||
# Idempotent replay uses the already fixed run even after the collection is gone.
|
||||
replay = await invoke(mcp_app, principal, "submit_backtests", submission(preparation_refs=refs))
|
||||
assert replay["backtest_run_id"] == result["backtest_run_id"]
|
||||
|
||||
Reference in New Issue
Block a user