From b71dce4e0f6917e4617ab1513d6e2c564293f367 Mon Sep 17 00:00:00 2001 From: Joshua Valluru <326636767+joshua-berri@users.noreply.github.com> Date: Tue, 20 Oct 2026 22:59:40 -0700 Subject: [PATCH] test: retarget reasoning and search assertions for mirrored catalog --- .../test_agentcore_search_transformation.py | 6 +++- .../test_openrouter_chat_transformation.py | 30 ++++++++++++------- .../llms/test_cache_control_and_reasoning.py | 27 ++++++++--------- 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/tests/test_litellm/llms/bedrock/search/test_agentcore_search_transformation.py b/tests/test_litellm/llms/bedrock/search/test_agentcore_search_transformation.py index 20bf65ee385..a20444ceca5 100644 --- a/tests/test_litellm/llms/bedrock/search/test_agentcore_search_transformation.py +++ b/tests/test_litellm/llms/bedrock/search/test_agentcore_search_transformation.py @@ -634,4 +634,8 @@ class TestAgentCoreSearchEdgeCases: from litellm.search.cost_calculator import search_provider_cost_per_query monkeypatch.setattr(litellm, "model_cost", GetModelCostMap.load_local_model_cost_map()) - assert search_provider_cost_per_query(model="agentcore/search", custom_llm_provider="agentcore") == (0.0, 0.0) + price_per_query = litellm.model_cost["agentcore/search"]["input_cost_per_query"] + assert price_per_query > 0 + assert search_provider_cost_per_query( + model="agentcore/search", custom_llm_provider="agentcore", number_of_queries=3 + ) == (3 * price_per_query, 0.0) diff --git a/tests/test_litellm/llms/openrouter/chat/test_openrouter_chat_transformation.py b/tests/test_litellm/llms/openrouter/chat/test_openrouter_chat_transformation.py index b177b80aed1..311956f7acb 100644 --- a/tests/test_litellm/llms/openrouter/chat/test_openrouter_chat_transformation.py +++ b/tests/test_litellm/llms/openrouter/chat/test_openrouter_chat_transformation.py @@ -1,5 +1,8 @@ import httpx +from typing import Final + +import litellm import pytest @@ -523,14 +526,14 @@ def test_openrouter_cost_tracking_streaming(): assert result2.usage.cost == 0.0001 -def test_openrouter_reasoning_models_allow_reasoning_effort_param(): +def test_openrouter_reasoning_models_allow_reasoning_effort_param(reasoning_model: str): """ OpenRouter reasoning-capable models should accept the reasoning_effort param. """ config = OpenrouterConfig() supported_params = config.get_supported_openai_params( - model="openrouter/deepseek/deepseek-v3.2" + model=reasoning_model ) assert "reasoning_effort" in supported_params @@ -550,7 +553,7 @@ def test_openrouter_non_reasoning_models_do_not_add_reasoning_effort(): assert "reasoning_effort" not in supported_params -def test_openrouter_reasoning_effort_max_maps_to_xhigh(): +def test_openrouter_reasoning_effort_max_maps_to_xhigh(reasoning_model: str): """ OpenRouter expects 'xhigh' instead of 'max' for reasoning_effort. """ @@ -559,14 +562,14 @@ def test_openrouter_reasoning_effort_max_maps_to_xhigh(): result = config.map_openai_params( non_default_params={"reasoning_effort": "max"}, optional_params={}, - model="openrouter/deepseek/deepseek-r1", + model=reasoning_model, drop_params=False, ) assert result["reasoning_effort"] == "xhigh" -def test_openrouter_reasoning_effort_max_does_not_mutate_caller_dict(): +def test_openrouter_reasoning_effort_max_does_not_mutate_caller_dict(reasoning_model: str): """ map_openai_params must not mutate the caller-supplied non_default_params dict. """ @@ -576,14 +579,14 @@ def test_openrouter_reasoning_effort_max_does_not_mutate_caller_dict(): config.map_openai_params( non_default_params=original_params, optional_params={}, - model="openrouter/deepseek/deepseek-r1", + model=reasoning_model, drop_params=False, ) assert original_params["reasoning_effort"] == "max" -def test_openrouter_reasoning_effort_xhigh_passes_through(): +def test_openrouter_reasoning_effort_xhigh_passes_through(reasoning_model: str): """ reasoning_effort='xhigh' should be forwarded unchanged. """ @@ -592,14 +595,14 @@ def test_openrouter_reasoning_effort_xhigh_passes_through(): result = config.map_openai_params( non_default_params={"reasoning_effort": "xhigh"}, optional_params={}, - model="openrouter/deepseek/deepseek-r1", + model=reasoning_model, drop_params=False, ) assert result["reasoning_effort"] == "xhigh" -def test_openrouter_reasoning_effort_high_passes_through(): +def test_openrouter_reasoning_effort_high_passes_through(reasoning_model: str): """ Non-max reasoning_effort values should be forwarded unchanged. """ @@ -608,8 +611,15 @@ def test_openrouter_reasoning_effort_high_passes_through(): result = config.map_openai_params( non_default_params={"reasoning_effort": "high"}, optional_params={}, - model="openrouter/deepseek/deepseek-r1", + model=reasoning_model, drop_params=False, ) assert result["reasoning_effort"] == "high" + + +@pytest.fixture +def reasoning_model(monkeypatch: pytest.MonkeyPatch) -> str: + model: Final = "openrouter/test-reasoning-model" + monkeypatch.setitem(litellm.model_cost, model, {"litellm_provider": "openrouter", "mode": "chat", "supports_reasoning": True}) + return model diff --git a/tests/test_litellm/llms/test_cache_control_and_reasoning.py b/tests/test_litellm/llms/test_cache_control_and_reasoning.py index be1ba1e7dbd..10b09b80686 100644 --- a/tests/test_litellm/llms/test_cache_control_and_reasoning.py +++ b/tests/test_litellm/llms/test_cache_control_and_reasoning.py @@ -8,6 +8,9 @@ This test file verifies the fixes for Issue #19923: """ +from typing import Final + +import litellm import pytest @@ -256,20 +259,14 @@ def test_openrouter_glm_transform_moves_cache_control_to_content(): assert user_message["content"][0]["cache_control"] == {"type": "ephemeral"} -def test_openrouter_supports_thinking_param_for_reasoning_models(): - """OpenRouter should support thinking parameter for reasoning-capable models.""" - config = OpenrouterConfig() +def test_openrouter_supports_thinking_param_for_reasoning_models(reasoning_model: str): + supported_params = OpenrouterConfig().get_supported_openai_params(model=reasoning_model) + assert "thinking" in supported_params + assert "reasoning_effort" in supported_params - # Test MiniMax (supports reasoning) - supported_params_minimax = config.get_supported_openai_params( - model="openrouter/minimax/minimax-m2" - ) - assert "thinking" in supported_params_minimax - assert "reasoning_effort" in supported_params_minimax - # Test GLM (supports reasoning) - supported_params_glm = config.get_supported_openai_params( - model="openrouter/z-ai/glm-4.6" - ) - assert "thinking" in supported_params_glm - assert "reasoning_effort" in supported_params_glm +@pytest.fixture +def reasoning_model(monkeypatch: pytest.MonkeyPatch) -> str: + model: Final = "openrouter/test-reasoning-model" + monkeypatch.setitem(litellm.model_cost, model, {"litellm_provider": "openrouter", "mode": "chat", "supports_reasoning": True}) + return model