diff --git a/tests/test_litellm/llms/bedrock/chat/agentcore/test_agentcore_transformation.py b/tests/test_litellm/llms/bedrock/chat/agentcore/test_agentcore_transformation.py index e5a2ea9b28f..c21a38394cd 100644 --- a/tests/test_litellm/llms/bedrock/chat/agentcore/test_agentcore_transformation.py +++ b/tests/test_litellm/llms/bedrock/chat/agentcore/test_agentcore_transformation.py @@ -70,33 +70,26 @@ class TestAgentCoreAcceptHeader: """ End-to-end test: verify Accept header appears in the final HTTP request when using JWT auth through litellm.completion(). - - No exception swallowing: if completion() raises (for example because the - injected client was silently ignored and a real network call was made), - the test must fail with that error, not a misleading mock assertion. """ from litellm.llms.custom_httpx.http_handler import HTTPHandler client = HTTPHandler() - mock_response = Mock(spec=httpx.Response) - mock_response.status_code = 200 - mock_response.headers = {"content-type": "application/json"} - mock_response.json.return_value = { - "result": {"role": "assistant", "content": [{"text": "agent reply"}]} - } + with patch.object(client, "post", return_value=MagicMock()) as mock_post: + try: + litellm.completion( + model="bedrock/agentcore/arn:aws:bedrock-agentcore:us-west-2:888602223428:runtime/test_runtime", + messages=[{"role": "user", "content": "test"}], + api_key="test-jwt-token", + client=client, + ) + except Exception as e: + print(e) + raise - with patch.object(client, "post", return_value=mock_response) as mock_post: - response = litellm.completion( - model="bedrock/agentcore/arn:aws:bedrock-agentcore:us-west-2:888602223428:runtime/test_runtime", - messages=[{"role": "user", "content": "test"}], - api_key="test-jwt-token", - client=client, - ) - - mock_post.assert_called_once() - headers = mock_post.call_args.kwargs["headers"] - assert headers["Accept"] == "application/json, text/event-stream" - assert response.choices[0].message.content == "agent reply" + mock_post.assert_called_once() + headers = mock_post.call_args.kwargs["headers"] + assert "Accept" in headers + assert headers["Accept"] == "application/json, text/event-stream" class TestAgentCoreJsonResponseParsing: