feat: bootstrap FastAPI configuration

This commit is contained in:
Bastian Wagner
2026-08-15 09:14:33 +02:00
parent c7e834bf14
commit 91728cba86
6 changed files with 119 additions and 0 deletions

0
tests/conftest.py Normal file
View File

32
tests/test_config.py Normal file
View File

@@ -0,0 +1,32 @@
from pathlib import Path
from app.config import Settings
def test_settings_build_default_data_paths(tmp_path: Path) -> None:
settings = Settings(
ADMIN_PASSWORD="admin-secret",
SECRET_KEY="session-secret-16chars",
CREDENTIAL_ENCRYPTION_KEY="ZmFrZS1rZXktZm9yLXRlc3RzLW11c3QtYmUtNDQtY2hhcnM=",
DATA_DIR=str(tmp_path),
SYNC_INTERVAL_MINUTES=5,
)
assert settings.data_dir == tmp_path
assert settings.database_url == f"sqlite:///{tmp_path / 'app.db'}"
assert settings.tokens_dir == tmp_path / "tokens"
assert settings.activities_dir == tmp_path / "activities"
def test_sync_interval_must_be_positive(tmp_path: Path) -> None:
try:
Settings(
ADMIN_PASSWORD="admin-secret",
SECRET_KEY="session-secret-16chars",
CREDENTIAL_ENCRYPTION_KEY="ZmFrZS1rZXktZm9yLXRlc3RzLW11c3QtYmUtNDQtY2hhcnM=",
DATA_DIR=str(tmp_path),
SYNC_INTERVAL_MINUTES=0,
)
except ValueError:
return
raise AssertionError("Expected validation failure for non-positive interval")