legco_ai_assistant/backend/app/test/test_phase9_config.py

75 lines
2.4 KiB
Python

"""Phase 9 tests: Config settings for accuracy testing & evaluation (Sub-Phase 9.0).
Covers:
- test_results_dir and test_evaluations_dir default values
- eval_chunk_batch_size = 10 (fixed)
- eval_max_concurrent_batches = 10 (rate limiting)
- eval_batch_retry_count = 2
- eval_batch_retry_delay_ms = 2000
- Env var overrides work correctly
"""
from app.core.config import Settings
class TestEvalConfigDefaults:
"""Default values for new Package 9 evaluation settings."""
def test_default_results_dir(self):
s = Settings()
assert s.test_results_dir == "./data/test_results"
def test_default_evaluations_dir(self):
s = Settings()
assert s.test_evaluations_dir == "./data/test_evaluations"
def test_default_chunk_batch_size(self):
s = Settings()
assert s.eval_chunk_batch_size == 10
def test_default_max_concurrent_batches(self):
s = Settings()
assert s.eval_max_concurrent_batches == 10
def test_default_batch_retry_count(self):
s = Settings()
assert s.eval_batch_retry_count == 2
def test_default_batch_retry_delay_ms(self):
s = Settings()
assert s.eval_batch_retry_delay_ms == 2000
class TestEvalConfigEnvOverrides:
"""Environment variable overrides for evaluation settings."""
def test_results_dir_from_env(self, monkeypatch):
monkeypatch.setenv("TEST_RESULTS_DIR", "/tmp/test_results")
s = Settings()
assert s.test_results_dir == "/tmp/test_results"
def test_evaluations_dir_from_env(self, monkeypatch):
monkeypatch.setenv("TEST_EVALUATIONS_DIR", "/tmp/test_eval")
s = Settings()
assert s.test_evaluations_dir == "/tmp/test_eval"
def test_chunk_batch_size_from_env(self, monkeypatch):
monkeypatch.setenv("EVAL_CHUNK_BATCH_SIZE", "5")
s = Settings()
assert s.eval_chunk_batch_size == 5
def test_max_concurrent_batches_from_env(self, monkeypatch):
monkeypatch.setenv("EVAL_MAX_CONCURRENT_BATCHES", "5")
s = Settings()
assert s.eval_max_concurrent_batches == 5
def test_batch_retry_count_from_env(self, monkeypatch):
monkeypatch.setenv("EVAL_BATCH_RETRY_COUNT", "3")
s = Settings()
assert s.eval_batch_retry_count == 3
def test_batch_retry_delay_ms_from_env(self, monkeypatch):
monkeypatch.setenv("EVAL_BATCH_RETRY_DELAY_MS", "5000")
s = Settings()
assert s.eval_batch_retry_delay_ms == 5000