feat: added proper settings handling

This commit is contained in:
2026-01-01 03:55:23 +01:00
parent 8b406370f1
commit c50091f6bf
23 changed files with 440 additions and 328 deletions

View File

@@ -5,7 +5,7 @@ from unittest.mock import patch
import pytest
from alfred.agent.config import ConfigurationError, Settings
from alfred.settings import Settings, ConfigurationError
from alfred.agent.parameters import (
REQUIRED_PARAMETERS,
ParameterSchema,
@@ -22,31 +22,31 @@ class TestSettingsEdgeCases:
with patch.dict(os.environ, {}, clear=True):
settings = Settings()
assert settings.temperature == 0.2
assert settings.max_tool_iterations == 5
assert settings.llm_temperature == 0.2
assert settings.max_tool_iterations == 10
assert settings.request_timeout == 30
def test_temperature_boundary_low(self):
"""Should accept temperature at lower boundary."""
with patch.dict(os.environ, {"TEMPERATURE": "0.0"}, clear=True):
with patch.dict(os.environ, {"LLM_TEMPERATURE": "0.0"}, clear=True):
settings = Settings()
assert settings.temperature == 0.0
assert settings.llm_temperature == 0.0
def test_temperature_boundary_high(self):
"""Should accept temperature at upper boundary."""
with patch.dict(os.environ, {"TEMPERATURE": "2.0"}, clear=True):
with patch.dict(os.environ, {"LLM_TEMPERATURE": "2.0"}, clear=True):
settings = Settings()
assert settings.temperature == 2.0
assert settings.llm_temperature == 2.0
def test_temperature_below_boundary(self):
"""Should reject temperature below 0."""
with patch.dict(os.environ, {"TEMPERATURE": "-0.1"}, clear=True):
with patch.dict(os.environ, {"LLM_TEMPERATURE": "-0.1"}, clear=True):
with pytest.raises(ConfigurationError):
Settings()
def test_temperature_above_boundary(self):
"""Should reject temperature above 2."""
with patch.dict(os.environ, {"TEMPERATURE": "2.1"}, clear=True):
with patch.dict(os.environ, {"LLM_TEMPERATURE": "2.1"}, clear=True):
with pytest.raises(ConfigurationError):
Settings()
@@ -162,7 +162,7 @@ class TestSettingsEdgeCases:
def test_non_numeric_temperature(self):
"""Should handle non-numeric temperature."""
with patch.dict(os.environ, {"TEMPERATURE": "not-a-number"}, clear=True):
with patch.dict(os.environ, {"LLM_TEMPERATURE": "not-a-number"}, clear=True):
with pytest.raises((ConfigurationError, ValueError)):
Settings()