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: ensure model_names is a O(1) datastructure

AlexsanderHamir56838e2388d9
diff --git a/tests/router_unit_tests/test_router_index_management.py b/tests/router_unit_tests/test_router_index_management.py
index 04ea9214991..63f9d118349 100644
--- a/tests/router_unit_tests/test_router_index_management.py
+++ b/tests/router_unit_tests/test_router_index_management.py
@@ -177,3 +177,11 @@ class TestRouterIndexManagement:
# Verify: New entry is added
assert "claude-3" in router.model_name_to_deployment_indices
assert router.model_name_to_deployment_indices["claude-3"] == [0]
+
+ def test_model_names_is_set(self):
+ """Verify that model_names uses a set for O(1) lookups, not a list (O(n))"""
+ router = Router(model_list=[])
+
+ assert isinstance(router.model_names, set), (
+ f"model_names should be a set for O(1) lookups, but got {type(router.model_names)}"
+ )