33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
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")
|