test: ensure model_names is a O(1) datastructure

This commit is contained in:
AlexsanderHamir 2025-10-15 17:52:44 -07:00
parent 3b14866d78
commit e154ab6a66

View file

@ -179,6 +179,14 @@ class TestRouterIndexManagement:
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)}"
)
def test_no_linear_scans_in_router(self):
"""
Static analysis test to ensure Router doesn't use O(n) linear scans.