mirror of
https://github.com/zvx-echo6/central.git
synced 2026-05-21 18:14:44 +02:00
chore(M-b): clear get_settings lru_cache in test fixtures (fixes order-dependent crypto failures + 3 latent siblings)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
69dddd0240
commit
f666014821
4 changed files with 65 additions and 12 deletions
|
|
@ -20,6 +20,7 @@ import pytest
|
|||
import pytest_asyncio
|
||||
|
||||
from central.config_models import AdapterConfig
|
||||
from central.bootstrap_config import get_settings
|
||||
from central.crypto import KEY_SIZE, clear_key_cache
|
||||
|
||||
|
||||
|
|
@ -56,11 +57,20 @@ def master_key_path(tmp_path_factory: pytest.TempPathFactory) -> Path:
|
|||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_master_key(master_key_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""Configure master key path for all tests."""
|
||||
clear_key_cache()
|
||||
def setup_master_key(master_key_path: Path, monkeypatch: pytest.MonkeyPatch):
|
||||
"""Configure master key path for all tests.
|
||||
|
||||
Clear get_settings (and the crypto key cache) AFTER setting the env so
|
||||
crypto rebuilds from the test key regardless of suite order, and again on
|
||||
teardown so the test key never leaks into a later test. See PR M-b.
|
||||
"""
|
||||
monkeypatch.setenv("CENTRAL_DB_DSN", TEST_DB_DSN)
|
||||
monkeypatch.setenv("CENTRAL_MASTER_KEY_PATH", str(master_key_path))
|
||||
clear_key_cache()
|
||||
get_settings.cache_clear()
|
||||
yield
|
||||
clear_key_cache()
|
||||
get_settings.cache_clear()
|
||||
|
||||
|
||||
class MockConfigSource:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue