From 0628d4f3e1f4146fbe5b2b4d784e7df2ae8fadd1 Mon Sep 17 00:00:00 2001 From: jtstothard Date: Tue, 21 Apr 2026 16:40:28 +0100 Subject: [PATCH] fix: update tests to call transform_responses_api_request for header validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes P1 issue flagged by Greptile: two tests were calling validate_environment() to assert headers that are now set in transform_responses_api_request(). Changes: - Renamed test_validate_environment_with_vision_header → test_transform_request_with_vision_header - Renamed test_validate_environment_with_x_initiator → test_transform_request_with_x_initiator - Updated both tests to call transform_responses_api_request() with proper parameters - Removed mock litellm_params.input usage (input is now a direct parameter) This aligns the tests with the actual implementation where X-Initiator and copilot-vision-request headers are set in transform_responses_api_request() where the input parameter is available. Co-Authored-By: Claude Sonnet 4.6 --- ...github_copilot_responses_transformation.py | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/tests/test_litellm/llms/github_copilot/responses/test_github_copilot_responses_transformation.py b/tests/test_litellm/llms/github_copilot/responses/test_github_copilot_responses_transformation.py index c5f70833fa7..d6dd9effd61 100644 --- a/tests/test_litellm/llms/github_copilot/responses/test_github_copilot_responses_transformation.py +++ b/tests/test_litellm/llms/github_copilot/responses/test_github_copilot_responses_transformation.py @@ -217,7 +217,7 @@ class TestGithubCopilotResponsesAPITransformation: assert has_vision is False, "Should return False for string input" @patch("litellm.llms.github_copilot.responses.transformation.Authenticator") - def test_validate_environment_with_vision_header(self, mock_authenticator_class): + def test_transform_request_with_vision_header(self, mock_authenticator_class): """Test that copilot-vision-request header is added for vision input""" mock_auth_instance = MagicMock() mock_auth_instance.get_api_key.return_value = "test-api-key" @@ -225,17 +225,21 @@ class TestGithubCopilotResponsesAPITransformation: config = GithubCopilotResponsesAPIConfig() - # Create mock litellm_params with input attribute - mock_litellm_params = MagicMock() - mock_litellm_params.input = [ + # Vision input with input_image type + input_with_vision = [ { "role": "user", "content": [{"type": "input_image", "data": "base64..."}], } ] - headers = config.validate_environment( - headers={}, model="gpt-5.1-codex", litellm_params=mock_litellm_params + headers = {} + config.transform_responses_api_request( + model="gpt-5.1-codex", + input=input_with_vision, + response_api_optional_request_params={}, + litellm_params={}, + headers=headers, ) assert ( @@ -243,7 +247,7 @@ class TestGithubCopilotResponsesAPITransformation: ), "Should add copilot-vision-request header for vision input" @patch("litellm.llms.github_copilot.responses.transformation.Authenticator") - def test_validate_environment_with_x_initiator(self, mock_authenticator_class): + def test_transform_request_with_x_initiator(self, mock_authenticator_class): """Test that X-Initiator header is set based on input""" mock_auth_instance = MagicMock() mock_auth_instance.get_api_key.return_value = "test-api-key" @@ -251,15 +255,19 @@ class TestGithubCopilotResponsesAPITransformation: config = GithubCopilotResponsesAPIConfig() - # Create mock litellm_params with input attribute - mock_litellm_params = MagicMock() - mock_litellm_params.input = [ + # Multi-turn input with assistant role + input_with_assistant = [ {"role": "user", "content": "Hello"}, {"role": "assistant", "content": "Hi"}, ] - headers = config.validate_environment( - headers={}, model="gpt-5.1-codex", litellm_params=mock_litellm_params + headers = {} + config.transform_responses_api_request( + model="gpt-5.1-codex", + input=input_with_assistant, + response_api_optional_request_params={}, + litellm_params={}, + headers=headers, ) assert (