MCPcopy Create free account
hub / github.com/alibaba/open-code-review / assert_execution

Function assert_execution

acp/testdata/python-client-smoke.py:129–153  ·  view source on GitHub ↗
(updates, status, expected_lines)

Source from the content-addressed store, hash-verified

127
128
129def assert_execution(updates, status, expected_lines):
130 calls = [u for u in updates if u["sessionUpdate"] == "tool_call"]
131 assert len(calls) == 1, calls
132 call = calls[0]
133 assert call["kind"] == "other" and not call.get("locations"), call
134 assert call["status"] == "in_progress"
135 changes = [u for u in updates if u["sessionUpdate"] == "tool_call_update"
136 and u["toolCallId"] == call["toolCallId"]]
137 assert changes and changes[-1]["status"] == status, changes
138 details = "".join(c["content"]["text"] for c in changes[-1].get("content", [])
139 if c.get("type") == "content" and c["content"].get("type") == "text")
140 details = details.replace("\r\n", "\n")
141 assert all(line in details for line in expected_lines), details
142 if len(expected_lines) > 1:
143 assert "\n".join(expected_lines) in details, details
144 assert "```text\n" in details, details
145 assert "Command:" in details and "Working directory:" in details, details
146 messages = "".join(u["content"].get("text", "") for u in updates
147 if u["sessionUpdate"] == "agent_message_chunk")
148 assert not any(line in messages for line in expected_lines), messages
149 assert "Command:" not in messages, messages
150 opening_details = "".join(c["content"]["text"] for c in call.get("content", [])
151 if c.get("type") == "content" and c["content"].get("type") == "text")
152 assert "Command:" in opening_details and "Working directory:" in opening_details, opening_details
153 assert changes[-1]["title"].startswith(("OCR review · ", "OCR scan · ")), changes[-1]
154
155
156

Callers 1

smokeFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected