42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
"""Unit tests for agent factory."""
|
|
|
|
from homeagent.agent.factory import create_agent
|
|
from homeagent.agent.gemini import GeminiAgent
|
|
from homeagent.agent.openai_agent import OpenAIAgent
|
|
from homeagent.config import Settings
|
|
|
|
|
|
def test_factory_creates_gemini_by_default(tmp_path):
|
|
settings = Settings(LLM_PROVIDER="gemini", DATA_DIR=tmp_path)
|
|
agent = create_agent(settings=settings)
|
|
assert isinstance(agent, GeminiAgent)
|
|
|
|
|
|
def test_factory_creates_deepseek(tmp_path):
|
|
settings = Settings(
|
|
LLM_PROVIDER="deepseek",
|
|
DEEPSEEK_API_KEY="sk-fake",
|
|
DEEPSEEK_MODEL="deepseek-chat",
|
|
DATA_DIR=tmp_path,
|
|
)
|
|
agent = create_agent(settings=settings)
|
|
assert isinstance(agent, OpenAIAgent)
|
|
assert agent.provider == "deepseek"
|
|
assert agent.base_url == "https://api.deepseek.com"
|
|
assert agent.model == "deepseek-chat"
|
|
|
|
|
|
def test_factory_creates_openai_compatible(tmp_path):
|
|
settings = Settings(
|
|
LLM_PROVIDER="openai",
|
|
OPENAI_API_KEY="sk-fake",
|
|
OPENAI_BASE_URL="https://openrouter.ai/api/v1",
|
|
OPENAI_MODEL="deepseek/deepseek-chat",
|
|
DATA_DIR=tmp_path,
|
|
)
|
|
agent = create_agent(settings=settings)
|
|
assert isinstance(agent, OpenAIAgent)
|
|
assert agent.provider == "openai"
|
|
assert agent.base_url == "https://openrouter.ai/api/v1"
|
|
assert agent.model == "deepseek/deepseek-chat"
|