fix(test): mock headers in test_completion_fine_tuned_model - #25444
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR fixes a spurious Confidence Score: 5/5Safe to merge — fixes a broken test mock with no production code changes. The only functional change is setting No files require special attention.
|
| Filename | Overview |
|---|---|
| tests/local_testing/test_amazing_vertex_completion.py | Fixes broken AsyncMock by explicitly setting headers = {} and status_code = 200 upfront; remaining changes are cosmetic blank-line removals. |
Sequence Diagram
sequenceDiagram
participant Test as test_completion_fine_tuned_model
participant LiteLLM as litellm.acompletion
participant Handler as AsyncHTTPHandler.post (patched)
participant Mock as mock_response
Test->>Mock: headers = {} (NEW)
Test->>Mock: status_code = 200
Test->>Mock: json = return_val
Test->>LiteLLM: acompletion(model, messages)
LiteLLM->>Handler: POST request (mocked)
Handler-->>LiteLLM: mock_response
LiteLLM->>Mock: headers.get("x-gemini-service-tier")
Mock-->>LiteLLM: None (empty dict, no branch taken)
LiteLLM->>Mock: json() → response dict
LiteLLM-->>Test: ModelResponse
Test->>Test: assert URL, payload, response fields
Reviews (2): Last reviewed commit: "format vertex test file" | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Hey, @joereyna Are you facing the same issue of formatting the 330 files in lint check |
Yes, seeing the same thing. |
|
@Bakul2006 this is a known issue, we are actively making the dev process more seamless around this. |
…e_tuned_model_test fix(test): mock headers in test_completion_fine_tuned_model
Summary
mock_response = AsyncMock()leftheadersas anAsyncMockattributeraw_response.headers.get("x-gemini-service-tier")returned a truthyAsyncMock, so the walrus operator assigned it toservice_tierservice_tier.lower()then failed withAttributeError: 'coroutine' object has no attribute 'lower'mock_response.headers = {}so the header lookup returnsNoneand the service tier branch is skippedTest plan
test_completion_fine_tuned_modelpasses in CI (requires real GCP credentials)