feat: schedule periodic user synchronization
This commit is contained in:
30
tests/test_main_lifespan.py
Normal file
30
tests/test_main_lifespan.py
Normal file
@@ -0,0 +1,30 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user