Replace ~80 manual os.getenv() calls in config.py with dynaconf-backed configuration, enabling TOML file-based config alongside existing env var support. Zero breaking changes — Settings dataclass interface and all consumers unchanged. Phase 1: Create settings.toml with all config keys and defaults, .secrets.toml.example template, update .gitignore, initialize Dynaconf instance with envvar_prefix=False and environment section switching. Phase 2: Wire adapter — replace os.getenv() with _dynaconf.get() in get_settings(), get_document_processor_config(), and deprecation/ dependency resolution helpers. Automatic type coercion eliminates ~30 manual int()/float()/.lower()=="true" patterns. Phase 3: Add 12 declarative validators for port ranges, positive integers, enum constraints, and float ranges. Remove redundant negative overlap check from Settings.__post_init__. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
22 lines
699 B
Python
22 lines
699 B
Python
"""Unit test configuration — shared fixtures for all unit tests."""
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _reload_dynaconf_after_test():
|
|
"""Ensure dynaconf cache is clean between tests.
|
|
|
|
Dynaconf caches env var values at load time. Tests that modify os.environ
|
|
must call _reload_config() to refresh the cache. This fixture reloads
|
|
after each test to prevent leaked state.
|
|
|
|
Uses _dynaconf.reload() directly (without validate_all) since the
|
|
real env may have values that don't pass validators. Tests that need
|
|
validation should call _reload_config() explicitly.
|
|
"""
|
|
yield
|
|
from nextcloud_mcp_server.config import _dynaconf
|
|
|
|
_dynaconf.reload()
|