The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: fix CI red — pool fixtures carry source, refresh assertion binds the failed key
Teknium07ddfaa2d6f9
diff --git a/tests/agent/test_anthropic_adapter.py b/tests/agent/test_anthropic_adapter.pyindex 3ded294a6c6..7ed804baa7f 100644--- a/tests/agent/test_anthropic_adapter.py+++ b/tests/agent/test_anthropic_adapter.py@@ -12,6 +12,7 @@ from agent.prompt_caching import apply_anthropic_cache_controlfrom agent.anthropic_adapter import build_anthropic_client, build_anthropic_bedrock_client, build_anthropic_kwargsfrom agent.anthropic_credentials import _is_oauth_token, _refresh_oauth_token, _write_claude_code_credentials, is_claude_code_token_valid, read_claude_code_credentials, resolve_anthropic_token, run_oauth_setup_tokenfrom agent.anthropic_endpoints import _is_azure_anthropic_endpoint+from agent.credential_pool import PooledCredentialfrom agent.anthropic_message_convert import _to_plain_data, convert_messages_to_anthropic, convert_tools_to_anthropic, normalize_model_namefrom agent.transports import get_transport@@ -272,10 +273,9 @@ class TestResolveAnthropicToken:# returns nothing, mirroring a Hermes-PKCE-only setup.monkeypatch.setattr("agent.anthropic_credentials.read_claude_code_credentials", lambda: None)- pool_entry = SimpleNamespace(- auth_type="oauth",- access_token="pool-oauth-token",- )+ pool_entry = PooledCredential.from_dict("anthropic", {+ "auth_type": "oauth", "access_token": "pool-oauth-token",+ })pool = SimpleNamespace(_available_entries=lambda **_kwargs: ([pool_entry], []),)@@ -330,7 +330,9 @@ class TestResolveAnthropicToken:monkeypatch.setattr("agent.anthropic_credentials.Path.home", lambda: tmp_path)monkeypatch.setattr("agent.anthropic_credentials.read_claude_code_credentials", lambda: None)- api_key_entry = SimpleNamespace(auth_type="api_key", access_token="sk-pool-apikey")+ api_key_entry = PooledCredential.from_dict("anthropic", {+ "auth_type": "api_key", "access_token": "sk-pool-apikey",+ })pool = SimpleNamespace(_available_entries=lambda **_kwargs: ([api_key_entry], []),)@@ -351,7 +353,9 @@ class TestResolveAnthropicToken:monkeypatch.setattr("agent.anthropic_credentials.read_claude_code_credentials", lambda: None)captured = {}- pool_entry = SimpleNamespace(auth_type="oauth", access_token="pool-oauth-token")+ pool_entry = PooledCredential.from_dict("anthropic", {+ "auth_type": "oauth", "access_token": "pool-oauth-token",+ })def _available_entries(**kwargs):captured.update(kwargs)diff --git a/tests/agent/test_auxiliary_client.py b/tests/agent/test_auxiliary_client.pyindex c88f2473633..44afecdb57a 100644--- a/tests/agent/test_auxiliary_client.py+++ b/tests/agent/test_auxiliary_client.py@@ -1724,6 +1724,7 @@ class TestStaleFallbackCandidateSkip:stale_fb = MagicMock()stale_fb.base_url = "https://api.anthropic.com"+ stale_fb.api_key = "expired-anthropic-token"stale_fb.chat.completions.create.side_effect = _AuxAuth401("Invalid bearer token")fresh_fb = MagicMock()@@ -1752,7 +1753,7 @@ class TestStaleFallbackCandidateSkip:)assert result.choices[0].message.content == "fresh-fallback"- mock_refresh.assert_called_once_with("anthropic")+ mock_refresh.assert_called_once_with("anthropic", failed_api_key=stale_fb.api_key)assert stale_fb.chat.completions.create.call_count == 1assert fresh_fb.chat.completions.create.call_count == 1