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

@@ -2,7 +2,7 @@
import pytest
from alfred.agent.config import ConfigurationError, Settings
from alfred.settings import Settings, ConfigurationError
class TestConfigValidation:
@@ -11,17 +11,17 @@ class TestConfigValidation:
def test_invalid_temperature_raises_error(self):
"""Verify invalid temperature is rejected."""
with pytest.raises(ConfigurationError, match="Temperature"):
Settings(temperature=3.0) # > 2.0
Settings(llm_temperature=3.0) # > 2.0
with pytest.raises(ConfigurationError, match="Temperature"):
Settings(temperature=-0.1) # < 0.0
Settings(llm_temperature=-0.1) # < 0.0
def test_valid_temperature_accepted(self):
"""Verify valid temperature is accepted."""
# Should not raise
Settings(temperature=0.0)
Settings(temperature=1.0)
Settings(temperature=2.0)
Settings(llm_temperature=0.0)
Settings(llm_temperature=1.0)
Settings(llm_temperature=2.0)
def test_invalid_max_iterations_raises_error(self):
"""Verify invalid max_iterations is rejected."""
@@ -126,7 +126,7 @@ class TestConfigDefaults:
"""Verify default temperature is reasonable."""
settings = Settings()
assert 0.0 <= settings.temperature <= 2.0
assert 0.0 <= settings.llm_temperature <= 2.0
def test_default_max_iterations(self):
"""Verify default max_iterations is reasonable."""
@@ -153,11 +153,11 @@ class TestConfigEnvironmentVariables:
def test_loads_temperature_from_env(self, monkeypatch):
"""Verify temperature is loaded from environment."""
monkeypatch.setenv("TEMPERATURE", "0.5")
monkeypatch.setenv("LLM_TEMPERATURE", "0.5")
settings = Settings()
assert settings.temperature == 0.5
assert settings.llm_temperature == 0.5
def test_loads_max_iterations_from_env(self, monkeypatch):
"""Verify max_iterations is loaded from environment."""
@@ -185,7 +185,7 @@ class TestConfigEnvironmentVariables:
def test_invalid_env_value_raises_error(self, monkeypatch):
"""Verify invalid environment value raises error."""
monkeypatch.setenv("TEMPERATURE", "invalid")
monkeypatch.setenv("LLM_TEMPERATURE", "invalid")
with pytest.raises(ValueError):
Settings()