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: cover runtime callback reconciliation

mateo3dea586d3be3
diff --git a/tests/test_litellm/test_router_retry_policy_update.py b/tests/test_litellm/test_router_retry_policy_update.py
index db710f76887..9e0bb0b9bef 100644
--- a/tests/test_litellm/test_router_retry_policy_update.py
+++ b/tests/test_litellm/test_router_retry_policy_update.py
@@ -135,6 +135,26 @@ def test_update_settings_clears_omitted_toggleable_pre_call_checks():
assert not any(isinstance(callback, PromptCachingDeploymentCheck) for callback in litellm.callbacks)
+def test_set_optional_pre_call_checks_reconciles_callback_types():
+ router = _build_router()
+
+ router.set_optional_pre_call_checks(["prompt_caching"])
+ router.set_optional_pre_call_checks([])
+
+ assert not any(isinstance(callback, PromptCachingDeploymentCheck) for callback in (router.optional_callbacks or []))
+ assert not any(isinstance(callback, PromptCachingDeploymentCheck) for callback in litellm.callbacks)
+
+
+def test_remove_optional_pre_call_check_removes_local_and_global_callbacks():
+ router = _build_router()
+
+ router.set_optional_pre_call_checks(["prompt_caching"])
+ router._remove_optional_callbacks_of_type(PromptCachingDeploymentCheck)
+
+ assert not any(isinstance(callback, PromptCachingDeploymentCheck) for callback in (router.optional_callbacks or []))
+ assert not any(isinstance(callback, PromptCachingDeploymentCheck) for callback in litellm.callbacks)
+
+
def test_update_settings_replaces_toggleable_pre_call_checks():
router = _build_router()