Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test: define local_model_cost_map fixture for migrated context caching tests

yunenga5033fff6e24
diff --git a/tests/unit/llms/vertex_ai/context_caching/test_vertex_ai_context_caching.py b/tests/unit/llms/vertex_ai/context_caching/test_vertex_ai_context_caching.py
index 4ba2d69a38b..a438b62c94c 100644
--- a/tests/unit/llms/vertex_ai/context_caching/test_vertex_ai_context_caching.py
+++ b/tests/unit/llms/vertex_ai/context_caching/test_vertex_ai_context_caching.py
@@ -4,6 +4,7 @@ from unittest.mock import AsyncMock, MagicMock, patch
import httpx
import pytest
+import litellm
from litellm.litellm_core_utils.litellm_logging import Logging
from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler, HTTPHandler
@@ -13,6 +14,25 @@ from litellm.llms.vertex_ai.context_caching.vertex_ai_context_caching import (
)
+def local_model_cost_map(monkeypatch):
+ """Force the bundled in-repo cost map so capability and pricing assertions do not
+ depend on the network-fetched ``main`` copy, which lags this branch until merge.
+
+ ``get_model_info`` is lru_cached, so swapping ``model_cost`` is not enough on its
+ own; clear on the way in and out so entries warmed against either map never leak
+ across tests."""
+ original_model_cost = litellm.model_cost
+ monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True")
+ litellm.model_cost = litellm.get_model_cost_map(url="")
+ litellm.get_model_info.cache_clear()
+ try:
+ yield
+ finally:
+ litellm.model_cost = original_model_cost
+ litellm.get_model_info.cache_clear()
+
+
class TestContextCachingEndpoints:
"""Test class for ContextCachingEndpoints methods"""