test: update test suite for Gemini integration
- Add mock_gemini parameter to test functions - Update Gemini API configuration tests - Fix date-based assertions in directory listing tests - Minor syntax fixes in test files
This commit is contained in:
parent
ffe5138a99
commit
cd49c2bd48
|
|
@ -175,7 +175,7 @@ def test_initialize_unsupported_provider(clean_env):
|
|||
initialize_llm("unsupported", "model")
|
||||
assert str(exc_info.value) == "Unsupported provider: unsupported"
|
||||
|
||||
def test_temperature_defaults(clean_env, mock_openai, mock_anthropic):
|
||||
def test_temperature_defaults(clean_env, mock_openai, mock_anthropic, mock_gemini):
|
||||
"""Test default temperature behavior for different providers."""
|
||||
os.environ["OPENAI_API_KEY"] = "test-key"
|
||||
os.environ["ANTHROPIC_API_KEY"] = "test-key"
|
||||
|
|
@ -209,11 +209,11 @@ def test_temperature_defaults(clean_env, mock_openai, mock_anthropic):
|
|||
model="test-model"
|
||||
)
|
||||
|
||||
def test_explicit_temperature(clean_env, mock_openai, mock_anthropic):
|
||||
def test_explicit_temperature(clean_env, mock_openai, mock_anthropic, mock_gemini):
|
||||
"""Test explicit temperature setting for each provider."""
|
||||
os.environ["OPENAI_API_KEY"] = "test-key"
|
||||
os.environ["ANTHROPIC_API_KEY"] = "test-key"
|
||||
os.environ["OPENROUTER_API_KEY"] = "test-key",
|
||||
os.environ["OPENROUTER_API_KEY"] = "test-key"
|
||||
os.environ["GEMINI_API_KEY"] = "test-key"
|
||||
|
||||
test_temp = 0.7
|
||||
|
|
@ -307,6 +307,10 @@ def test_initialize_llm_cross_provider(clean_env, mock_openai, mock_anthropic, m
|
|||
model_name="claude-3"
|
||||
)
|
||||
mock_gemini.assert_called_once_with(
|
||||
api_key="gemini-key",
|
||||
model="gemini-2.0-flash-thinking-exp-1219"
|
||||
)
|
||||
|
||||
def test_environment_variable_precedence(clean_env, mock_openai, monkeypatch):
|
||||
"""Test environment variable precedence and fallback."""
|
||||
from ra_aid.env import validate_environment
|
||||
|
|
|
|||
|
|
@ -199,20 +199,12 @@ def test_incomplete_gemini_config(clean_env):
|
|||
result = strategy.validate()
|
||||
assert not result.valid
|
||||
assert "GEMINI_API_KEY environment variable is not set" in result.missing_vars
|
||||
assert "GEMINI_MODEL environment variable is not set" in result.missing_vars
|
||||
|
||||
# Only API key
|
||||
# Valid API key
|
||||
os.environ["GEMINI_API_KEY"] = "test-key"
|
||||
result = strategy.validate()
|
||||
assert not result.valid
|
||||
assert "GEMINI_MODEL environment variable is not set" in result.missing_vars
|
||||
|
||||
# Only model
|
||||
os.environ.pop("GEMINI_API_KEY")
|
||||
os.environ["GEMINI_MODEL"] = "gemini-2.0-flash-exp"
|
||||
result = strategy.validate()
|
||||
assert not result.valid
|
||||
assert "GEMINI_API_KEY environment variable is not set" in result.missing_vars
|
||||
assert result.valid
|
||||
assert not result.missing_vars
|
||||
|
||||
def test_incomplete_expert_config(clean_env):
|
||||
"""Test expert provider with incomplete configuration."""
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
import os
|
||||
import pytest
|
||||
import tempfile
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from ra_aid.tools import list_directory_tree
|
||||
from ra_aid.tools.list_directory import load_gitignore_patterns, should_ignore
|
||||
|
||||
EXPECTED_YEAR = str(datetime.now().year)
|
||||
|
||||
@pytest.fixture
|
||||
def temp_dir():
|
||||
"""Create a temporary directory for testing"""
|
||||
|
|
@ -68,7 +71,7 @@ def test_list_directory_with_details(temp_dir):
|
|||
|
||||
# File details should be present
|
||||
assert "bytes" in result.lower() or "kb" in result.lower() or "b" in result.lower()
|
||||
assert "2024-" in result
|
||||
assert f"{EXPECTED_YEAR}-" in result
|
||||
|
||||
def test_list_directory_depth_limit(temp_dir):
|
||||
"""Test max_depth parameter"""
|
||||
|
|
|
|||
Loading…
Reference in New Issue