type: narrow optional results in integration tests

This commit is contained in:
lda
2026-08-29 19:02:40 +07:00 Verified
parent 96030a06fe
commit ac09a577a2
6 changed files with 67 additions and 33 deletions
@@ -275,8 +275,10 @@ async def test_browser_click_workflow_artifact_deployment_run_path(tmp_path) ->
) )
assert run["status"] == "completed" assert run["status"] == "completed"
assert run["output"]["before"]["clicked"] is False output = run["output"]
assert run["output"]["after"]["clicked"] is True assert output is not None
assert run["output"]["after"]["status_text"] == "Button clicked" assert output["before"]["clicked"] is False
assert run["output"]["closed"] is True assert output["after"]["clicked"] is True
assert output["after"]["status_text"] == "Button clicked"
assert output["closed"] is True
assert run["trace_count"] >= 3 assert run["trace_count"] >= 3
+10 -6
View File
@@ -63,13 +63,15 @@ async def test_report_workflow_python_source_loads_and_calls_capability(
) )
assert result["outcome"] == "ok" assert result["outcome"] == "ok"
assert result["output"]["title"] == "Weekly Project Update" output = result["output"]
assert result["output"]["action_items"][0] == { assert output is not None
assert output["title"] == "Weekly Project Update"
assert output["action_items"][0] == {
"owner": "Alice", "owner": "Alice",
"task": "Prepare demo config", "task": "Prepare demo config",
"due": "Friday", "due": "Friday",
} }
assert "Google Drive MCP quota" in result["output"]["risks"][0] assert "Google Drive MCP quota" in output["risks"][0]
@pytest.mark.asyncio @pytest.mark.asyncio
@@ -103,9 +105,11 @@ async def test_report_workflow_artifact_deployment_run_path(tmp_path) -> None:
) )
assert run["status"] == "completed" assert run["status"] == "completed"
assert run["output"]["report"]["title"] == "Weekly Project Update" output = run["output"]
assert len(run["output"]["report"]["action_items"]) == 3 assert output is not None
assert run["output"]["markdown"].startswith("# Weekly Project Update") assert output["report"]["title"] == "Weekly Project Update"
assert len(output["report"]["action_items"]) == 3
assert output["markdown"].startswith("# Weekly Project Update")
def test_report_workflow_read_notes_accepts_text_by_value() -> None: def test_report_workflow_read_notes_accepts_text_by_value() -> None:
@@ -34,7 +34,9 @@ def test_mcp_workflow_surface_example_runs_happy_path(tmp_path) -> None:
payload = asyncio.run(create_and_run_echo_deployment(tmp_path, text="hello")) payload = asyncio.run(create_and_run_echo_deployment(tmp_path, text="hello"))
assert payload["status"] == "completed" assert payload["status"] == "completed"
assert payload["output"]["echoed"] == "hello" output = payload["output"]
assert output is not None
assert output["echoed"] == "hello"
assert payload["diagnostics"] == [] assert payload["diagnostics"] == []
+26 -13
View File
@@ -123,22 +123,27 @@ def test_interrupting_saved_child_pauses_and_resumes_through_deployment_surface(
) )
assert paused["status"] == "interrupted" assert paused["status"] == "interrupted"
assert isinstance(paused["run_id"], str) paused_run_id = paused["run_id"]
assert paused["interrupt"]["node_id"] == "child_step" assert isinstance(paused_run_id, str)
assert paused["interrupt"]["payload"]["question"] == "hello" interrupt = paused["interrupt"]
assert interrupt is not None
assert interrupt["node_id"] == "child_step"
assert interrupt["payload"]["question"] == "hello"
# Durable resume must not rely on the process-local handler instance. # Durable resume must not rely on the process-local handler instance.
handlers = _handlers(store, tmp_path) handlers = _handlers(store, tmp_path)
resumed = asyncio.run( resumed = asyncio.run(
handlers.resume_run( handlers.resume_run(
run_id=paused["run_id"], run_id=paused_run_id,
resume_payload={"answer": "world"}, resume_payload={"answer": "world"},
) )
) )
assert resumed["status"] == "completed" assert resumed["status"] == "completed"
assert resumed["outcome"] == "ok" assert resumed["outcome"] == "ok"
assert resumed["output"]["echoed"] == "world" output = resumed["output"]
assert output is not None
assert output["echoed"] == "world"
def test_interrupted_saved_child_blocks_resume_until_pinned_source_returns( def test_interrupted_saved_child_blocks_resume_until_pinned_source_returns(
@@ -158,11 +163,13 @@ def test_interrupted_saved_child_blocks_resume_until_pinned_source_returns(
) )
run_store = handlers.service.run_store run_store = handlers.service.run_store
assert run_store is not None assert run_store is not None
paused_run_id = paused["run_id"]
assert isinstance(paused_run_id, str)
handlers.service.capability_sources["demo.personal"].enabled = False handlers.service.capability_sources["demo.personal"].enabled = False
blocked = asyncio.run( blocked = asyncio.run(
handlers.resume_run( handlers.resume_run(
run_id=paused["run_id"], run_id=paused_run_id,
resume_payload={"answer": "world"}, resume_payload={"answer": "world"},
) )
) )
@@ -171,22 +178,24 @@ def test_interrupted_saved_child_blocks_resume_until_pinned_source_returns(
assert blocked["resume_readiness"] == "blocked" assert blocked["resume_readiness"] == "blocked"
assert blocked["diagnostics"][0]["code"] == "source_disabled" assert blocked["diagnostics"][0]["code"] == "source_disabled"
assert ( assert (
run_store.get_run(paused["run_id"]).resume_readiness is ResumeReadiness.BLOCKED run_store.get_run(paused_run_id).resume_readiness is ResumeReadiness.BLOCKED
) )
assert run_store.get_latest_checkpoint(paused["run_id"]).sequence == 1 assert run_store.get_latest_checkpoint(paused_run_id).sequence == 1
handlers.service.capability_sources["demo.personal"].enabled = True handlers.service.capability_sources["demo.personal"].enabled = True
resumed = asyncio.run( resumed = asyncio.run(
handlers.resume_run( handlers.resume_run(
run_id=paused["run_id"], run_id=paused_run_id,
resume_payload={"answer": "world"}, resume_payload={"answer": "world"},
) )
) )
assert resumed["status"] == "completed" assert resumed["status"] == "completed"
assert resumed["resume_readiness"] == "not_applicable" assert resumed["resume_readiness"] == "not_applicable"
assert resumed["output"]["echoed"] == "world" output = resumed["output"]
assert run_store.get_latest_checkpoint(paused["run_id"]).sequence == 2 assert output is not None
assert output["echoed"] == "world"
assert run_store.get_latest_checkpoint(paused_run_id).sequence == 2
def test_missing_saved_child_is_unrunnable_on_deployment_surface( def test_missing_saved_child_is_unrunnable_on_deployment_surface(
@@ -241,7 +250,9 @@ def test_saved_child_runs_natively_with_parent_deployment_binding(
) )
assert result["status"] == "completed" assert result["status"] == "completed"
assert result["output"]["echoed"] == "hello" output = result["output"]
assert output is not None
assert output["echoed"] == "hello"
assert result["diagnostics"] == [] assert result["diagnostics"] == []
@@ -267,7 +278,9 @@ def test_nested_saved_child_inherits_root_deployment_binding(tmp_path: Path) ->
) )
assert result["status"] == "completed" assert result["status"] == "completed"
assert result["output"]["echoed"] == "hello" output = result["output"]
assert output is not None
assert output["echoed"] == "hello"
assert result["diagnostics"] == [] assert result["diagnostics"] == []
@@ -96,7 +96,9 @@ def test_workflow_surface_calls_saved_wrapper_artifact() -> None:
assert payload["kind"] == "wrapper_artifact" assert payload["kind"] == "wrapper_artifact"
assert payload["diagnostics"] == [] assert payload["diagnostics"] == []
assert payload["outcome"] == "completed" assert payload["outcome"] == "completed"
assert payload["output"]["echoed"] == "hello" output = payload["output"]
assert output is not None
assert output["echoed"] == "hello"
def test_workflow_surface_calls_live_node_spec_with_self_describing_response() -> None: def test_workflow_surface_calls_live_node_spec_with_self_describing_response() -> None:
@@ -124,7 +126,9 @@ def test_workflow_surface_calls_live_node_spec_with_self_describing_response() -
assert payload["kind"] == "node_spec" assert payload["kind"] == "node_spec"
assert payload["diagnostics"] == [] assert payload["diagnostics"] == []
assert payload["outcome"] == "ok" assert payload["outcome"] == "ok"
assert payload["output"]["echoed"] == "hello" output = payload["output"]
assert output is not None
assert output["echoed"] == "hello"
def test_workflow_surface_calls_saved_wrapper_artifact_with_deployment_bindings() -> ( def test_workflow_surface_calls_saved_wrapper_artifact_with_deployment_bindings() -> (
@@ -169,4 +173,6 @@ def test_workflow_surface_calls_saved_wrapper_artifact_with_deployment_bindings(
assert payload["deployment_id"] == "logical_echo_wrapper.personal" assert payload["deployment_id"] == "logical_echo_wrapper.personal"
assert payload["diagnostics"] == [] assert payload["diagnostics"] == []
assert payload["outcome"] == "completed" assert payload["outcome"] == "completed"
assert payload["output"]["echoed"] == "hello" output = payload["output"]
assert output is not None
assert output["echoed"] == "hello"
+13 -6
View File
@@ -102,10 +102,13 @@ async def test_local_static_server_runs_deployment_and_persists_run(tmp_path) ->
assert artifact_result["artifact_id"] == "server_constant" assert artifact_result["artifact_id"] == "server_constant"
assert deployment_result["deployment_id"] == "server_constant.default" assert deployment_result["deployment_id"] == "server_constant.default"
assert run_result["status"] == "completed" assert run_result["status"] == "completed"
assert run_result["output"]["result"] == "hello from server" output = run_result["output"]
assert isinstance(run_result["run_id"], str) assert output is not None
assert output["result"] == "hello from server"
run_id = run_result["run_id"]
assert isinstance(run_id, str)
assert ( assert (
server.stores.run_store.get_run(run_result["run_id"]).id == run_result["run_id"] server.stores.run_store.get_run(run_id).id == run_id
) )
@@ -132,10 +135,12 @@ async def test_local_static_server_inspects_and_reads_bounded_trace(tmp_path) ->
run_result = await api.run_deployment( run_result = await api.run_deployment(
deployment_id="server_trace.default", workflow_input={} deployment_id="server_trace.default", workflow_input={}
) )
run_id = run_result["run_id"]
assert isinstance(run_id, str)
summary = await api.inspect_run(run_id=run_result["run_id"]) summary = await api.inspect_run(run_id=run_id)
trace = await api.read_run_trace( trace = await api.read_run_trace(
run_id=run_result["run_id"], run_id=run_id,
trace_range=server.trace_range(start=0, limit=1), trace_range=server.trace_range(start=0, limit=1),
) )
@@ -177,7 +182,9 @@ async def test_local_static_wf_std_deployment_runs_without_source_binding(
assert artifact_result["artifact_id"] == "server_constant_no_binding" assert artifact_result["artifact_id"] == "server_constant_no_binding"
assert deployment_result["deployment_id"] == "server_constant_no_binding.default" assert deployment_result["deployment_id"] == "server_constant_no_binding.default"
assert run_result["status"] == "completed" assert run_result["status"] == "completed"
assert run_result["output"]["result"] == "hello from server" output = run_result["output"]
assert output is not None
assert output["result"] == "hello from server"
def test_local_static_server_has_no_source_registry_admin(tmp_path) -> None: def test_local_static_server_has_no_source_registry_admin(tmp_path) -> None: