Files
home-automation/tests/test_config.py
T

22 lines
1.1 KiB
Python

from app.config import Settings
def test_settings_support_two_independent_database_urls(monkeypatch) -> None:
monkeypatch.setenv("LOCATION_DATABASE_URL", "sqlite:///./data/locationRecorder.db")
monkeypatch.setenv("POO_DATABASE_URL", "sqlite:///./data/pooRecorder.db")
monkeypatch.setenv("HOME_ASSISTANT_BASE_URL", "http://ha.local:8123")
monkeypatch.setenv("HOME_ASSISTANT_AUTH_TOKEN", "token")
monkeypatch.setenv("HOME_ASSISTANT_TIMEOUT_SECONDS", "2.5")
settings = Settings()
assert settings.location_database_url == "sqlite:///./data/locationRecorder.db"
assert settings.poo_database_url == "sqlite:///./data/pooRecorder.db"
assert settings.home_assistant_base_url == "http://ha.local:8123"
assert settings.home_assistant_auth_token == "token"
assert settings.home_assistant_timeout_seconds == 2.5
assert settings.location_sqlite_path is not None
assert settings.location_sqlite_path.name == "locationRecorder.db"
assert settings.poo_sqlite_path is not None
assert settings.poo_sqlite_path.name == "pooRecorder.db"