mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-06 18:23:07 +00:00
Merge pull request #22720 from BerriAI/fix/proxy-utils-mock-request-state
fix: use real State in mock_request for proxy_utils tests
This commit is contained in:
@@ -8,6 +8,7 @@ from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
from fastapi import Request
|
||||
from starlette.datastructures import State
|
||||
|
||||
from litellm.proxy.utils import _get_docs_url, _get_redoc_url
|
||||
|
||||
@@ -32,6 +33,7 @@ def mock_request(monkeypatch):
|
||||
mock_request = Mock(spec=Request)
|
||||
mock_request.query_params = {} # Set mock query_params to an empty dictionary
|
||||
mock_request.headers = {"traceparent": "test_traceparent"}
|
||||
mock_request.state = State() # Real State so _safe_get_request_headers caching works
|
||||
monkeypatch.setattr(
|
||||
"litellm.proxy.litellm_pre_call_utils.add_litellm_data_to_request", mock_request
|
||||
)
|
||||
@@ -810,6 +812,7 @@ async def test_add_litellm_data_to_request_duplicate_tags(
|
||||
mock_request.url.path = "/chat/completions"
|
||||
mock_request.query_params = {}
|
||||
mock_request.headers = {}
|
||||
mock_request.state = State()
|
||||
|
||||
# Setup key with tags in metadata
|
||||
user_api_key_dict = UserAPIKeyAuth(
|
||||
|
||||
Reference in New Issue
Block a user