"""Unit tests for Redis URL auth helper (R-055).""" from app.core.redis_url import redis_url_has_auth, redis_url_with_auth class TestRedisUrlWithAuth: def test_injects_password(self): url = redis_url_with_auth("redis://localhost:6379/0", "secret") assert url == "redis://:secret@localhost:6379/0" assert redis_url_has_auth(url) def test_skips_when_password_present(self): url = "redis://:existing@localhost:6379/0" assert redis_url_with_auth(url, "new") == url def test_empty_password_unchanged(self): url = "redis://localhost:6379/0" assert redis_url_with_auth(url, "") == url assert not redis_url_has_auth(url)