fix(tests): patch a2a_tools_memory.httpx, not a2a_tools.httpx
Iter 4c (#2890) moved tool_commit_memory + tool_recall_memory into a2a_tools_memory.py, which has its own top-level `import httpx`. test_mcp_memory.py + the secret-redact memory tests still patched `a2a_tools.httpx.AsyncClient`, which after the move is the WRONG module's reference — the real call inside the moved tool resolves to `a2a_tools_memory.httpx.AsyncClient` and reaches the network. CI catches this as 7 failures: JSONDecodeError on empty bodies and "All connection attempts failed" on the recall side. Update 7 patch sites to `a2a_tools_memory.httpx.AsyncClient`. The existing tests in `test_a2a_tools_impl.py` were already updated by the iter-4c PR; only these two files were missed. Verified: pytest workspace/tests/test_mcp_memory.py + test_secret_redact.py — 43/43 pass after the fix (both files were red on the iter-4c branch CI). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
210a26d31a
commit
46a4ef83bb
@ -63,7 +63,7 @@ async def test_commit_memory_success(monkeypatch):
|
||||
mcp = _load_mcp()
|
||||
|
||||
client = FakeClient()
|
||||
monkeypatch.setattr("a2a_tools.httpx.AsyncClient", lambda **kw: client)
|
||||
monkeypatch.setattr("a2a_tools_memory.httpx.AsyncClient", lambda **kw: client)
|
||||
|
||||
result = await mcp.handle_tool_call("commit_memory", {
|
||||
"content": "Architecture decision: use Go for backend",
|
||||
@ -92,7 +92,7 @@ async def test_commit_memory_default_scope(monkeypatch):
|
||||
mcp = _load_mcp()
|
||||
|
||||
client = FakeClient()
|
||||
monkeypatch.setattr("a2a_tools.httpx.AsyncClient", lambda **kw: client)
|
||||
monkeypatch.setattr("a2a_tools_memory.httpx.AsyncClient", lambda **kw: client)
|
||||
|
||||
result = await mcp.handle_tool_call("commit_memory", {
|
||||
"content": "Some note",
|
||||
@ -108,7 +108,7 @@ async def test_recall_memory_success(monkeypatch):
|
||||
mcp = _load_mcp()
|
||||
|
||||
client = FakeClient()
|
||||
monkeypatch.setattr("a2a_tools.httpx.AsyncClient", lambda **kw: client)
|
||||
monkeypatch.setattr("a2a_tools_memory.httpx.AsyncClient", lambda **kw: client)
|
||||
|
||||
result = await mcp.handle_tool_call("recall_memory", {"query": "architecture"})
|
||||
|
||||
@ -127,7 +127,7 @@ async def test_recall_memory_empty(monkeypatch):
|
||||
async def get(self, url, params=None, headers=None, **kwargs):
|
||||
return FakeResponse(200, [])
|
||||
|
||||
monkeypatch.setattr("a2a_tools.httpx.AsyncClient", lambda **kw: EmptyClient())
|
||||
monkeypatch.setattr("a2a_tools_memory.httpx.AsyncClient", lambda **kw: EmptyClient())
|
||||
|
||||
result = await mcp.handle_tool_call("recall_memory", {})
|
||||
assert "No memories found" in result
|
||||
@ -139,7 +139,7 @@ async def test_recall_memory_with_scope_filter(monkeypatch):
|
||||
mcp = _load_mcp()
|
||||
|
||||
client = FakeClient()
|
||||
monkeypatch.setattr("a2a_tools.httpx.AsyncClient", lambda **kw: client)
|
||||
monkeypatch.setattr("a2a_tools_memory.httpx.AsyncClient", lambda **kw: client)
|
||||
|
||||
await mcp.handle_tool_call("recall_memory", {"scope": "TEAM"})
|
||||
|
||||
|
||||
@ -357,7 +357,7 @@ class TestA2AToolCommitMemoryRedactsSecrets:
|
||||
|
||||
fake_client.post = _capture
|
||||
|
||||
with patch("a2a_tools.httpx.AsyncClient", return_value=fake_client):
|
||||
with patch("a2a_tools_memory.httpx.AsyncClient", return_value=fake_client):
|
||||
await a2a_tools.tool_commit_memory(content_with_secret)
|
||||
|
||||
stored = captured.get("content", "")
|
||||
@ -385,7 +385,7 @@ class TestA2AToolCommitMemoryRedactsSecrets:
|
||||
|
||||
fake_client.post = _capture
|
||||
|
||||
with patch("a2a_tools.httpx.AsyncClient", return_value=fake_client):
|
||||
with patch("a2a_tools_memory.httpx.AsyncClient", return_value=fake_client):
|
||||
await a2a_tools.tool_commit_memory(f"key={key}")
|
||||
|
||||
stored = captured.get("content", "")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user