initial tests

This commit is contained in:
2026-02-12 18:52:24 -07:00
parent 3d5ec7a134
commit 577d390e7b
4 changed files with 143 additions and 0 deletions
+56
View File
@@ -0,0 +1,56 @@
"""
Shared test fixtures and config.
Fixtures defined here available to all tests
"""
from statistics import mode
from unittest.mock import AsyncMock, MagicMock
import pytest
from anthropic.types import ContentBlock, Message, TextBlock, Usage
from agent.config import Settings
@pytest.fixture
def settings():
"""provide test settings don't load from .env"""
return Settings(
anthropic_api_key="test-key-12345",
model="claude-test-model",
max_tokens=100,
safedir="./test-workspace",
)
@pytest.fixture
def mock_anthropic_client():
"""Mock anthropic client that returns a fake response."""
mock_client = AsyncMock()
# create a realistic fake response
fake_message = Message(
id="msg_test123",
type="message",
role="assistant",
content=[TextBlock(type="text", text="42")],
model="claude-test-model",
stop_reason="end_turn",
usage=Usage(input_tokens=10, output_tokens=5),
)
# make messages.create() return this fake message
mock_client.messages.create = AsyncMock(return_value=fake_message)
return mock_client
@pytest.fixture
def sample_history():
"""sample conversation history for testing"""
return [
{"role": "user", "content": "Hello"},
{"role": "assistance", "content": "Hi there!"},
{"role": "user", "content": "What's 2+2?"},
]