31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
from pathlib import Path
|
|
|
|
from cryptography.fernet import Fernet
|
|
from fastapi.testclient import TestClient
|
|
|
|
from app.config import Settings
|
|
from app.main import create_app
|
|
from app.sync.manager import SyncManager
|
|
|
|
|
|
def test_lifespan_wires_sync_manager_and_scheduler(tmp_path: Path) -> None:
|
|
settings = Settings(
|
|
ADMIN_PASSWORD="admin-secret",
|
|
SECRET_KEY="0123456789abcdef0123456789abcdef",
|
|
CREDENTIAL_ENCRYPTION_KEY=Fernet.generate_key().decode("ascii"),
|
|
DATA_DIR=str(tmp_path),
|
|
DATABASE_URL=f"sqlite:///{tmp_path / 'app.db'}",
|
|
SYNC_INTERVAL_MINUTES=5,
|
|
)
|
|
app = create_app(settings)
|
|
|
|
# No users are seeded in this database, so sync_all_enabled() has nothing
|
|
# to iterate over and the real MyWhoosh/Garmin factories are never invoked.
|
|
with TestClient(app):
|
|
assert app.state.sync_manager is not None
|
|
assert isinstance(app.state.sync_manager, SyncManager)
|
|
assert app.state.scheduler is not None
|
|
assert app.state.scheduler.last_tick is not None
|
|
|
|
app.state.db_engine.dispose()
|