diff --git a/tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py b/tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py index 922c374418..98161402c4 100644 --- a/tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py +++ b/tests/test_litellm/proxy/pass_through_endpoints/test_llm_pass_through_endpoints.py @@ -446,12 +446,16 @@ class TestVertexAIPassThroughHandler: "litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints.create_pass_through_route" ) as mock_create_route, mock.patch( "litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints.get_vertex_pass_through_handler" - ) as mock_get_handler: + ) as mock_get_handler, mock.patch( + "litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints.user_api_key_auth", + new_callable=AsyncMock, + ) as mock_auth: # Mock credentials object with necessary attributes mock_credentials = Mock() mock_credentials.token = default_credentials mock_load_auth.return_value = (mock_credentials, default_project) + mock_auth.return_value = MagicMock() # Mock the vertex handler mock_handler = Mock() diff --git a/tests/test_litellm/proxy/spend_tracking/test_spend_management_endpoints.py b/tests/test_litellm/proxy/spend_tracking/test_spend_management_endpoints.py index 6e34d27548..c3639e88f6 100644 --- a/tests/test_litellm/proxy/spend_tracking/test_spend_management_endpoints.py +++ b/tests/test_litellm/proxy/spend_tracking/test_spend_management_endpoints.py @@ -1977,28 +1977,34 @@ async def test_view_spend_logs_with_date_range_summarized(client, monkeypatch): start_date = (datetime.now(timezone.utc) - timedelta(days=2)).strftime("%Y-%m-%d") end_date = datetime.now(timezone.utc).strftime("%Y-%m-%d") - # Call the endpoint with both start and end dates. - # We don't need `summarize=true` as it's the default. - response = client.get( - "/spend/logs", - params={ - "start_date": start_date, - "end_date": end_date, - }, - headers={"Authorization": "Bearer sk-test"}, + app.dependency_overrides[ps.user_api_key_auth] = lambda: UserAPIKeyAuth( + user_role=LitellmUserRoles.PROXY_ADMIN ) + try: + # Call the endpoint with both start and end dates. + # We don't need `summarize=true` as it's the default. + response = client.get( + "/spend/logs", + params={ + "start_date": start_date, + "end_date": end_date, + }, + headers={"Authorization": "Bearer sk-test"}, + ) - # ASSERTIONS - assert response.status_code == 200 - data = response.json() + # ASSERTIONS + assert response.status_code == 200 + data = response.json() - # Check that the response is not empty and has the summarized structure. - assert isinstance(data, list) - assert len(data) > 0 - assert "startTime" in data[0] - assert "spend" in data[0] - assert "users" in data[0] - assert "models" in data[0] + # Check that the response is not empty and has the summarized structure. + assert isinstance(data, list) + assert len(data) > 0 + assert "startTime" in data[0] + assert "spend" in data[0] + assert "users" in data[0] + assert "models" in data[0] + finally: + app.dependency_overrides.pop(ps.user_api_key_auth, None) @pytest.mark.asyncio