Formatting
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
"""Critical tests for configuration validation."""
|
||||
|
||||
import pytest
|
||||
import os
|
||||
|
||||
from agent.config import Settings, ConfigurationError
|
||||
import pytest
|
||||
|
||||
from agent.config import ConfigurationError, Settings
|
||||
|
||||
|
||||
class TestConfigValidation:
|
||||
@@ -13,7 +13,7 @@ class TestConfigValidation:
|
||||
"""Verify invalid temperature is rejected."""
|
||||
with pytest.raises(ConfigurationError, match="Temperature"):
|
||||
Settings(temperature=3.0) # > 2.0
|
||||
|
||||
|
||||
with pytest.raises(ConfigurationError, match="Temperature"):
|
||||
Settings(temperature=-0.1) # < 0.0
|
||||
|
||||
@@ -28,7 +28,7 @@ class TestConfigValidation:
|
||||
"""Verify invalid max_iterations is rejected."""
|
||||
with pytest.raises(ConfigurationError, match="max_tool_iterations"):
|
||||
Settings(max_tool_iterations=0) # < 1
|
||||
|
||||
|
||||
with pytest.raises(ConfigurationError, match="max_tool_iterations"):
|
||||
Settings(max_tool_iterations=100) # > 20
|
||||
|
||||
@@ -43,7 +43,7 @@ class TestConfigValidation:
|
||||
"""Verify invalid timeout is rejected."""
|
||||
with pytest.raises(ConfigurationError, match="request_timeout"):
|
||||
Settings(request_timeout=0) # < 1
|
||||
|
||||
|
||||
with pytest.raises(ConfigurationError, match="request_timeout"):
|
||||
Settings(request_timeout=500) # > 300
|
||||
|
||||
@@ -58,7 +58,7 @@ class TestConfigValidation:
|
||||
"""Verify invalid DeepSeek URL is rejected."""
|
||||
with pytest.raises(ConfigurationError, match="Invalid deepseek_base_url"):
|
||||
Settings(deepseek_base_url="not-a-url")
|
||||
|
||||
|
||||
with pytest.raises(ConfigurationError, match="Invalid deepseek_base_url"):
|
||||
Settings(deepseek_base_url="ftp://invalid.com")
|
||||
|
||||
@@ -86,19 +86,17 @@ class TestConfigChecks:
|
||||
def test_is_deepseek_configured_with_key(self):
|
||||
"""Verify is_deepseek_configured returns True with API key."""
|
||||
settings = Settings(
|
||||
deepseek_api_key="test-key",
|
||||
deepseek_base_url="https://api.test.com"
|
||||
deepseek_api_key="test-key", deepseek_base_url="https://api.test.com"
|
||||
)
|
||||
|
||||
|
||||
assert settings.is_deepseek_configured() is True
|
||||
|
||||
def test_is_deepseek_configured_without_key(self):
|
||||
"""Verify is_deepseek_configured returns False without API key."""
|
||||
settings = Settings(
|
||||
deepseek_api_key="",
|
||||
deepseek_base_url="https://api.test.com"
|
||||
deepseek_api_key="", deepseek_base_url="https://api.test.com"
|
||||
)
|
||||
|
||||
|
||||
assert settings.is_deepseek_configured() is False
|
||||
|
||||
def test_is_deepseek_configured_without_url(self):
|
||||
@@ -110,19 +108,15 @@ class TestConfigChecks:
|
||||
def test_is_tmdb_configured_with_key(self):
|
||||
"""Verify is_tmdb_configured returns True with API key."""
|
||||
settings = Settings(
|
||||
tmdb_api_key="test-key",
|
||||
tmdb_base_url="https://api.test.com"
|
||||
tmdb_api_key="test-key", tmdb_base_url="https://api.test.com"
|
||||
)
|
||||
|
||||
|
||||
assert settings.is_tmdb_configured() is True
|
||||
|
||||
def test_is_tmdb_configured_without_key(self):
|
||||
"""Verify is_tmdb_configured returns False without API key."""
|
||||
settings = Settings(
|
||||
tmdb_api_key="",
|
||||
tmdb_base_url="https://api.test.com"
|
||||
)
|
||||
|
||||
settings = Settings(tmdb_api_key="", tmdb_base_url="https://api.test.com")
|
||||
|
||||
assert settings.is_tmdb_configured() is False
|
||||
|
||||
|
||||
@@ -132,25 +126,25 @@ class TestConfigDefaults:
|
||||
def test_default_temperature(self):
|
||||
"""Verify default temperature is reasonable."""
|
||||
settings = Settings()
|
||||
|
||||
|
||||
assert 0.0 <= settings.temperature <= 2.0
|
||||
|
||||
def test_default_max_iterations(self):
|
||||
"""Verify default max_iterations is reasonable."""
|
||||
settings = Settings()
|
||||
|
||||
|
||||
assert 1 <= settings.max_tool_iterations <= 20
|
||||
|
||||
def test_default_timeout(self):
|
||||
"""Verify default timeout is reasonable."""
|
||||
settings = Settings()
|
||||
|
||||
|
||||
assert 1 <= settings.request_timeout <= 300
|
||||
|
||||
def test_default_urls_are_valid(self):
|
||||
"""Verify default URLs are valid."""
|
||||
settings = Settings()
|
||||
|
||||
|
||||
assert settings.deepseek_base_url.startswith(("http://", "https://"))
|
||||
assert settings.tmdb_base_url.startswith(("http://", "https://"))
|
||||
|
||||
@@ -161,38 +155,38 @@ class TestConfigEnvironmentVariables:
|
||||
def test_loads_temperature_from_env(self, monkeypatch):
|
||||
"""Verify temperature is loaded from environment."""
|
||||
monkeypatch.setenv("TEMPERATURE", "0.5")
|
||||
|
||||
|
||||
settings = Settings()
|
||||
|
||||
|
||||
assert settings.temperature == 0.5
|
||||
|
||||
def test_loads_max_iterations_from_env(self, monkeypatch):
|
||||
"""Verify max_iterations is loaded from environment."""
|
||||
monkeypatch.setenv("MAX_TOOL_ITERATIONS", "10")
|
||||
|
||||
|
||||
settings = Settings()
|
||||
|
||||
|
||||
assert settings.max_tool_iterations == 10
|
||||
|
||||
def test_loads_timeout_from_env(self, monkeypatch):
|
||||
"""Verify timeout is loaded from environment."""
|
||||
monkeypatch.setenv("REQUEST_TIMEOUT", "60")
|
||||
|
||||
|
||||
settings = Settings()
|
||||
|
||||
|
||||
assert settings.request_timeout == 60
|
||||
|
||||
def test_loads_deepseek_url_from_env(self, monkeypatch):
|
||||
"""Verify DeepSeek URL is loaded from environment."""
|
||||
monkeypatch.setenv("DEEPSEEK_BASE_URL", "https://custom.api.com")
|
||||
|
||||
|
||||
settings = Settings()
|
||||
|
||||
|
||||
assert settings.deepseek_base_url == "https://custom.api.com"
|
||||
|
||||
def test_invalid_env_value_raises_error(self, monkeypatch):
|
||||
"""Verify invalid environment value raises error."""
|
||||
monkeypatch.setenv("TEMPERATURE", "invalid")
|
||||
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
Settings()
|
||||
|
||||
Reference in New Issue
Block a user