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")
|
initialize_llm("unsupported", "model")
|
||||||
assert str(exc_info.value) == "Unsupported provider: unsupported"
|
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."""
|
"""Test default temperature behavior for different providers."""
|
||||||
os.environ["OPENAI_API_KEY"] = "test-key"
|
os.environ["OPENAI_API_KEY"] = "test-key"
|
||||||
os.environ["ANTHROPIC_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"
|
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."""
|
"""Test explicit temperature setting for each provider."""
|
||||||
os.environ["OPENAI_API_KEY"] = "test-key"
|
os.environ["OPENAI_API_KEY"] = "test-key"
|
||||||
os.environ["ANTHROPIC_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"
|
os.environ["GEMINI_API_KEY"] = "test-key"
|
||||||
|
|
||||||
test_temp = 0.7
|
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"
|
model_name="claude-3"
|
||||||
)
|
)
|
||||||
mock_gemini.assert_called_once_with(
|
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):
|
def test_environment_variable_precedence(clean_env, mock_openai, monkeypatch):
|
||||||
"""Test environment variable precedence and fallback."""
|
"""Test environment variable precedence and fallback."""
|
||||||
from ra_aid.env import validate_environment
|
from ra_aid.env import validate_environment
|
||||||
|
|
|
||||||
|
|
@ -199,20 +199,12 @@ def test_incomplete_gemini_config(clean_env):
|
||||||
result = strategy.validate()
|
result = strategy.validate()
|
||||||
assert not result.valid
|
assert not result.valid
|
||||||
assert "GEMINI_API_KEY environment variable is not set" in result.missing_vars
|
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"
|
os.environ["GEMINI_API_KEY"] = "test-key"
|
||||||
result = strategy.validate()
|
result = strategy.validate()
|
||||||
assert not result.valid
|
assert result.valid
|
||||||
assert "GEMINI_MODEL environment variable is not set" in result.missing_vars
|
assert not 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
|
|
||||||
|
|
||||||
def test_incomplete_expert_config(clean_env):
|
def test_incomplete_expert_config(clean_env):
|
||||||
"""Test expert provider with incomplete configuration."""
|
"""Test expert provider with incomplete configuration."""
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
import tempfile
|
import tempfile
|
||||||
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from ra_aid.tools import list_directory_tree
|
from ra_aid.tools import list_directory_tree
|
||||||
from ra_aid.tools.list_directory import load_gitignore_patterns, should_ignore
|
from ra_aid.tools.list_directory import load_gitignore_patterns, should_ignore
|
||||||
|
|
||||||
|
EXPECTED_YEAR = str(datetime.now().year)
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def temp_dir():
|
def temp_dir():
|
||||||
"""Create a temporary directory for testing"""
|
"""Create a temporary directory for testing"""
|
||||||
|
|
@ -68,7 +71,7 @@ def test_list_directory_with_details(temp_dir):
|
||||||
|
|
||||||
# File details should be present
|
# File details should be present
|
||||||
assert "bytes" in result.lower() or "kb" in result.lower() or "b" in result.lower()
|
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):
|
def test_list_directory_depth_limit(temp_dir):
|
||||||
"""Test max_depth parameter"""
|
"""Test max_depth parameter"""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue