From 46a4ef83bbe4e0fa6fcc2001e8c3f2005847625f Mon Sep 17 00:00:00 2001 From: Hongming Wang Date: Tue, 5 May 2026 13:24:57 -0700 Subject: [PATCH] fix(tests): patch a2a_tools_memory.httpx, not a2a_tools.httpx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- workspace/tests/test_mcp_memory.py | 10 +++++----- workspace/tests/test_secret_redact.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/workspace/tests/test_mcp_memory.py b/workspace/tests/test_mcp_memory.py index 117e5417..d2a7ac35 100644 --- a/workspace/tests/test_mcp_memory.py +++ b/workspace/tests/test_mcp_memory.py @@ -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"}) diff --git a/workspace/tests/test_secret_redact.py b/workspace/tests/test_secret_redact.py index d0975969..ecc268e8 100644 --- a/workspace/tests/test_secret_redact.py +++ b/workspace/tests/test_secret_redact.py @@ -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", "")