37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
from app import config as config_module
|
|
|
|
|
|
def test_settings_normalize_docker_aliases_for_host_runtime(monkeypatch):
|
|
monkeypatch.setattr(config_module, "_is_running_in_container", lambda: False)
|
|
|
|
settings = config_module.Settings(
|
|
postgres_host="postgres",
|
|
redis_url="redis://redis:6379/0",
|
|
)
|
|
|
|
assert settings.postgres_host == "localhost"
|
|
assert settings.redis_url == "redis://localhost:6379/0"
|
|
assert settings.database_url == "postgresql+asyncpg://hartomat:hartomat@localhost:5432/hartomat"
|
|
|
|
|
|
def test_settings_preserve_service_aliases_inside_container(monkeypatch):
|
|
monkeypatch.setattr(config_module, "_is_running_in_container", lambda: True)
|
|
|
|
settings = config_module.Settings(
|
|
postgres_host="postgres",
|
|
redis_url="redis://redis:6379/0",
|
|
)
|
|
|
|
assert settings.postgres_host == "postgres"
|
|
assert settings.redis_url == "redis://redis:6379/0"
|
|
|
|
|
|
def test_normalize_service_url_preserves_auth_and_query(monkeypatch):
|
|
monkeypatch.setattr(config_module, "_is_running_in_container", lambda: False)
|
|
|
|
normalized = config_module._normalize_service_url(
|
|
"redis://user:secret@redis:6380/1?ssl_cert_reqs=none"
|
|
)
|
|
|
|
assert normalized == "redis://user:secret@localhost:6380/1?ssl_cert_reqs=none"
|