feat: bootstrap FastAPI configuration
This commit is contained in:
0
tests/conftest.py
Normal file
0
tests/conftest.py
Normal file
32
tests/test_config.py
Normal file
32
tests/test_config.py
Normal 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")
|
||||
Reference in New Issue
Block a user