"""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"