M1-T05: drop location/poo database config from Settings and tests
Remove the dead location_database_url / poo_database_url fields and the location_sqlite_path / poo_sqlite_path computed properties from Settings; drop them from the config-page payload and from .env.example. Update the test hardcodes (test_config, test_public_ip, test_smtp) and reduce the conftest test_database_urls fixture to the single app DB. The one-time migration script keeps reading legacy URLs from env/CLI, independent of Settings. pytest 95 passed; ruff clean (pre-existing only).
This commit is contained in:
@@ -20,15 +20,9 @@ def _make_app_alembic_config(database_url: str) -> Config:
|
||||
@pytest.fixture
|
||||
def test_database_urls(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
|
||||
app_database_path = tmp_path / "app_test.db"
|
||||
location_database_path = tmp_path / "location_test.db"
|
||||
poo_database_path = tmp_path / "poo_placeholder.db"
|
||||
app_database_url = f"sqlite:///{app_database_path}"
|
||||
location_database_url = f"sqlite:///{location_database_path}"
|
||||
poo_database_url = f"sqlite:///{poo_database_path}"
|
||||
|
||||
monkeypatch.setenv("APP_DATABASE_URL", app_database_url)
|
||||
monkeypatch.setenv("LOCATION_DATABASE_URL", location_database_url)
|
||||
monkeypatch.setenv("POO_DATABASE_URL", poo_database_url)
|
||||
monkeypatch.setenv("AUTH_BOOTSTRAP_USERNAME", "admin")
|
||||
monkeypatch.setenv("AUTH_BOOTSTRAP_PASSWORD", "test-password")
|
||||
monkeypatch.setenv("AUTH_COOKIE_SECURE_OVERRIDE", "false")
|
||||
@@ -39,10 +33,6 @@ def test_database_urls(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
|
||||
yield {
|
||||
"app_path": app_database_path,
|
||||
"app_url": app_database_url,
|
||||
"location_path": location_database_path,
|
||||
"location_url": location_database_url,
|
||||
"poo_path": poo_database_path,
|
||||
"poo_url": poo_database_url,
|
||||
}
|
||||
finally:
|
||||
get_settings.cache_clear()
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
from app.config import Settings
|
||||
|
||||
|
||||
def test_settings_support_two_independent_database_urls(monkeypatch) -> None:
|
||||
def test_settings_load_core_fields_from_env(monkeypatch) -> None:
|
||||
monkeypatch.setenv("APP_DATABASE_URL", "sqlite:///./data/app.db")
|
||||
monkeypatch.setenv("LOCATION_DATABASE_URL", "sqlite:///./data/locationRecorder.db")
|
||||
monkeypatch.setenv("POO_DATABASE_URL", "sqlite:///./data/pooRecorder.db")
|
||||
monkeypatch.setenv("APP_HOSTNAME", "home.example.com")
|
||||
monkeypatch.setenv("POO_WEBHOOK_ID", "poo-hook")
|
||||
monkeypatch.setenv("POO_SENSOR_ENTITY_NAME", "sensor.test_poo_status")
|
||||
@@ -21,8 +19,6 @@ def test_settings_support_two_independent_database_urls(monkeypatch) -> None:
|
||||
settings = Settings(_env_file=None)
|
||||
|
||||
assert settings.app_database_url == "sqlite:///./data/app.db"
|
||||
assert settings.location_database_url == "sqlite:///./data/locationRecorder.db"
|
||||
assert settings.poo_database_url == "sqlite:///./data/pooRecorder.db"
|
||||
assert settings.poo_webhook_id == "poo-hook"
|
||||
assert settings.poo_sensor_entity_name == "sensor.test_poo_status"
|
||||
assert settings.poo_sensor_friendly_name == "Poo Status"
|
||||
@@ -36,12 +32,8 @@ def test_settings_support_two_independent_database_urls(monkeypatch) -> None:
|
||||
assert settings.auth_bootstrap_password == "secret"
|
||||
assert settings.auth_session_cookie_name == "auth_cookie"
|
||||
assert settings.auth_session_ttl_hours == 8
|
||||
assert settings.location_sqlite_path is not None
|
||||
assert settings.location_sqlite_path.name == "locationRecorder.db"
|
||||
assert settings.app_sqlite_path is not None
|
||||
assert settings.app_sqlite_path.name == "app.db"
|
||||
assert settings.poo_sqlite_path is not None
|
||||
assert settings.poo_sqlite_path.name == "pooRecorder.db"
|
||||
assert settings.auth_cookie_secure is True
|
||||
|
||||
|
||||
|
||||
@@ -182,8 +182,6 @@ def _notification_settings() -> Settings:
|
||||
app_env="development",
|
||||
app_hostname="localhost:8000",
|
||||
app_database_url="sqlite:///./data/app.db",
|
||||
location_database_url="sqlite:///./data/locationRecorder.db",
|
||||
poo_database_url="sqlite:///./data/pooRecorder.db",
|
||||
auth_bootstrap_username="admin",
|
||||
auth_bootstrap_password="secret-password",
|
||||
smtp_enabled=True,
|
||||
|
||||
@@ -40,8 +40,6 @@ def _smtp_settings(**overrides) -> Settings:
|
||||
"app_env": "development",
|
||||
"app_hostname": "localhost:8000",
|
||||
"app_database_url": "sqlite:///./data/app.db",
|
||||
"location_database_url": "sqlite:///./data/locationRecorder.db",
|
||||
"poo_database_url": "sqlite:///./data/pooRecorder.db",
|
||||
"auth_bootstrap_username": "admin",
|
||||
"auth_bootstrap_password": "secret-password",
|
||||
"smtp_enabled": True,
|
||||
|
||||
Reference in New Issue
Block a user