initial tests
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
"""test config"""
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from agent.config import Settings
|
||||
|
||||
|
||||
def test_settings_with_all_values():
|
||||
"""Test Settings loads correctly with all values provided."""
|
||||
settings = Settings(
|
||||
anthropic_api_key="sk-ant-test",
|
||||
model="claude-test",
|
||||
max_tokens=500,
|
||||
safedir="/tmp/test",
|
||||
)
|
||||
|
||||
assert settings.anthropic_api_key == "sk-ant-test"
|
||||
assert settings.model == "claude-test"
|
||||
assert settings.max_tokens == 500
|
||||
|
||||
|
||||
def test_settings_defaults():
|
||||
"""Test Settings uses defaults for optional values."""
|
||||
settings = Settings(
|
||||
anthropic_api_key="sk-ant-test" # Only required field
|
||||
)
|
||||
|
||||
# Should use defaults
|
||||
assert settings.model == "claude-sonnet-4-5-20250929"
|
||||
assert settings.max_tokens == 500
|
||||
|
||||
|
||||
def test_settings_missing_required_field():
|
||||
"""Test Settings raises error when required field is missing."""
|
||||
with pytest.raises(ValidationError) as exc_info:
|
||||
Settings(_env_file=None) # Missing anthropic_api_key
|
||||
|
||||
# Verify the error mentions the missing field
|
||||
assert "anthropic_api_key" in str(exc_info.value)
|
||||
|
||||
|
||||
def test_settings_type_validation():
|
||||
"""Test Settings validates types correctly."""
|
||||
with pytest.raises(ValidationError):
|
||||
Settings(
|
||||
anthropic_api_key="sk-ant-test",
|
||||
max_tokens="not-a-number", # Should be int
|
||||
)
|
||||
Reference in New Issue
Block a user