Add config and client injection with test reorganization.

Introduce typed config objects, optional adapter injection, and .env loading to simplify testing while preserving env-based defaults for production usage.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Brian Bjarke Jensen
2026-07-06 20:44:08 +02:00
co-authored by Cursor
parent 366831ac52
commit 7991dabdbc
28 changed files with 645 additions and 377 deletions
+27
View File
@@ -0,0 +1,27 @@
"""Unit tests for RedisConfig."""
from __future__ import annotations
import pytest
from python_repositories.config import RedisConfig
def test_from_env_loads_uri(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setenv("REDIS_URI", "redis://example:6379")
config = RedisConfig.from_env(use_dotenv=False)
assert config.uri == "redis://example:6379"
def test_from_env_raises_when_uri_missing(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.delenv("REDIS_URI", raising=False)
with pytest.raises(Exception):
RedisConfig.from_env(use_dotenv=False)
def test_from_env_respects_custom_env_var_name(
monkeypatch: pytest.MonkeyPatch,
) -> None:
monkeypatch.setenv("CUSTOM_REDIS_URI", "redis://custom:6379")
config = RedisConfig.from_env("CUSTOM_REDIS_URI", use_dotenv=False)
assert config.uri == "redis://custom:6379"