fix tests

This commit is contained in:
AI Christianson 2025-02-25 18:38:00 -05:00
parent 9c76745bcc
commit 840abf96f7
1 changed files with 44 additions and 35 deletions

View File

@ -99,13 +99,16 @@ def test_initialize_expert_anthropic(clean_env, mock_anthropic, monkeypatch):
monkeypatch.setenv("EXPERT_ANTHROPIC_API_KEY", "test-key") monkeypatch.setenv("EXPERT_ANTHROPIC_API_KEY", "test-key")
_llm = initialize_expert_llm("anthropic", "claude-3") _llm = initialize_expert_llm("anthropic", "claude-3")
mock_anthropic.assert_called_once_with( # Check that mock_anthropic was called
api_key="test-key", assert mock_anthropic.called
model_name="claude-3",
temperature=0, # Verify essential parameters
timeout=180, kwargs = mock_anthropic.call_args.kwargs
max_retries=5, assert kwargs["api_key"] == "test-key"
) assert kwargs["model_name"] == "claude-3"
assert kwargs["temperature"] == 0
assert kwargs["timeout"] == 180
assert kwargs["max_retries"] == 5
def test_initialize_expert_openrouter(clean_env, mock_openai, monkeypatch): def test_initialize_expert_openrouter(clean_env, mock_openai, monkeypatch):
@ -198,13 +201,16 @@ def test_initialize_anthropic(clean_env, mock_anthropic):
os.environ["ANTHROPIC_API_KEY"] = "test-key" os.environ["ANTHROPIC_API_KEY"] = "test-key"
_model = initialize_llm("anthropic", "claude-3", temperature=0.7) _model = initialize_llm("anthropic", "claude-3", temperature=0.7)
mock_anthropic.assert_called_with( # Check that mock_anthropic was called
api_key="test-key", assert mock_anthropic.called
model_name="claude-3",
temperature=0.7, # Verify essential parameters
timeout=180, kwargs = mock_anthropic.call_args.kwargs
max_retries=5, assert kwargs["api_key"] == "test-key"
) assert kwargs["model_name"] == "claude-3"
assert kwargs["temperature"] == 0.7
assert kwargs["timeout"] == 180
assert kwargs["max_retries"] == 5
def test_initialize_openrouter(clean_env, mock_openai): def test_initialize_openrouter(clean_env, mock_openai):
@ -279,13 +285,14 @@ def test_temperature_defaults(clean_env, mock_openai, mock_anthropic, mock_gemin
) )
initialize_llm("anthropic", "test-model") initialize_llm("anthropic", "test-model")
mock_anthropic.assert_called_with(
api_key="test-key", # Verify essential parameters for Anthropic
model_name="test-model", kwargs = mock_anthropic.call_args.kwargs
temperature=0.7, assert kwargs["api_key"] == "test-key"
timeout=180, assert kwargs["model_name"] == "test-model"
max_retries=5, assert kwargs["temperature"] == 0.7
) assert kwargs["timeout"] == 180
assert kwargs["max_retries"] == 5
initialize_llm("gemini", "test-model") initialize_llm("gemini", "test-model")
mock_gemini.assert_called_with( mock_gemini.assert_called_with(
@ -347,13 +354,14 @@ def test_explicit_temperature(clean_env, mock_openai, mock_anthropic, mock_gemin
# Test Anthropic # Test Anthropic
initialize_llm("anthropic", "test-model", temperature=test_temp) initialize_llm("anthropic", "test-model", temperature=test_temp)
mock_anthropic.assert_called_with(
api_key="test-key", # Verify essential parameters for Anthropic
model_name="test-model", kwargs = mock_anthropic.call_args.kwargs
temperature=test_temp, assert kwargs["api_key"] == "test-key"
timeout=180, assert kwargs["model_name"] == "test-model"
max_retries=5, assert kwargs["temperature"] == test_temp
) assert kwargs["timeout"] == 180
assert kwargs["max_retries"] == 5
# Test OpenRouter # Test OpenRouter
initialize_llm("openrouter", "test-model", temperature=test_temp) initialize_llm("openrouter", "test-model", temperature=test_temp)
@ -474,13 +482,14 @@ def test_initialize_llm_cross_provider(
# Initialize Anthropic # Initialize Anthropic
monkeypatch.setenv("ANTHROPIC_API_KEY", "anthropic-key") monkeypatch.setenv("ANTHROPIC_API_KEY", "anthropic-key")
_llm2 = initialize_llm("anthropic", "claude-3", temperature=0.7) _llm2 = initialize_llm("anthropic", "claude-3", temperature=0.7)
mock_anthropic.assert_called_with(
api_key="anthropic-key", # Verify essential parameters for Anthropic
model_name="claude-3", kwargs = mock_anthropic.call_args.kwargs
temperature=0.7, assert kwargs["api_key"] == "anthropic-key"
timeout=180, assert kwargs["model_name"] == "claude-3"
max_retries=5, assert kwargs["temperature"] == 0.7
) assert kwargs["timeout"] == 180
assert kwargs["max_retries"] == 5
# Initialize Gemini # Initialize Gemini
monkeypatch.setenv("GEMINI_API_KEY", "gemini-key") monkeypatch.setenv("GEMINI_API_KEY", "gemini-key")