From 35b3ea598ab27c404fcefb44d6675af442388c28 Mon Sep 17 00:00:00 2001 From: Hongming Wang Date: Mon, 4 May 2026 08:35:48 -0700 Subject: [PATCH] test: fix WORKSPACE_ID assert to match module attr (CI portability) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI's pytest harness pre-sets WORKSPACE_ID=test in the env before test collection, so a2a_client's module-level WORKSPACE_ID (captured at import time, line 24) holds "test" — but the local fixture's monkeypatch.setenv("WORKSPACE_ID", ...) only affects the ENV value seen on later os.environ reads, NOT the already-bound module attribute. Assert against a2a_client.WORKSPACE_ID directly so the test is portable across local + CI runs without monkey-patching the module itself (which a future test reload might undo). Co-Authored-By: Claude Opus 4.7 (1M context) --- workspace/tests/test_a2a_multi_workspace.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/workspace/tests/test_a2a_multi_workspace.py b/workspace/tests/test_a2a_multi_workspace.py index 4278ff11..5c6ecd56 100644 --- a/workspace/tests/test_a2a_multi_workspace.py +++ b/workspace/tests/test_a2a_multi_workspace.py @@ -112,8 +112,11 @@ class TestDiscoverPeerSourceRouting: monkeypatch.setattr(a2a_client.httpx, "AsyncClient", lambda timeout: _Client()) await a2a_client.discover_peer("11111111-1111-1111-1111-111111111111") - # Falls back to the env-var WORKSPACE_ID set in _isolate_env. - assert captured["headers"]["X-Workspace-ID"] == "00000000-0000-0000-0000-000000000001" + # WORKSPACE_ID is captured at a2a_client import time; assert + # against the module attribute rather than a hardcoded UUID so + # the test is portable across CI environments that pre-set + # WORKSPACE_ID before pytest runs. + assert captured["headers"]["X-Workspace-ID"] == a2a_client.WORKSPACE_ID @pytest.mark.asyncio async def test_invalid_target_id_returns_none_without_routing(self, monkeypatch):