mirror of
https://github.com/sstent/FitTrack_GarminSync.git
synced 2026-01-26 00:51:44 +00:00
Complete spec: Code alignment and documentation cleanup
- Ensure code aligns with CentralDB models - Document code alignment with CentralDB models - Remove informal reference documents (data-model.md, DB_API_SPEC.json, GARMINSYNC_SPEC.md) - Run linters and formatters (black, isort, mypy) - Update project configuration files - Add .dockerignore for Docker builds - Perform code formatting and import sorting - Fix type checking issues - Update documentation files - Complete implementation tasks as per spec
This commit is contained in:
@@ -1,5 +1,16 @@
|
||||
import pytest
|
||||
from backend.src.services.sync_manager import CurrentSyncJobManager
|
||||
|
||||
from backend.src.services.sync_manager import (
|
||||
CurrentSyncJobManager,
|
||||
current_sync_job_manager,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
async def reset_sync_manager_state():
|
||||
"""Resets the singleton instance's state before each test."""
|
||||
current_sync_job_manager._current_job = None
|
||||
yield
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -44,3 +55,30 @@ async def test_fail_sync():
|
||||
status = await manager.get_current_sync_status()
|
||||
assert status.status == "failed"
|
||||
assert status.error_message == "Test error"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_cancel_sync():
|
||||
manager = CurrentSyncJobManager()
|
||||
await manager.start_sync("activities")
|
||||
await manager.cancel_sync()
|
||||
status = await manager.get_current_sync_status()
|
||||
assert status.status == "cancelled"
|
||||
assert status.cancellation_requested is True
|
||||
assert status.end_time is not None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_cancel_sync_when_not_active():
|
||||
manager = CurrentSyncJobManager()
|
||||
# No sync started
|
||||
await manager.cancel_sync()
|
||||
status = await manager.get_current_sync_status()
|
||||
assert status is None
|
||||
|
||||
# Sync completed
|
||||
await manager.start_sync("activities")
|
||||
await manager.complete_sync()
|
||||
await manager.cancel_sync()
|
||||
status = await manager.get_current_sync_status()
|
||||
assert status.status == "completed" # Should not change after completion
|
||||
|
||||
Reference in New Issue
Block a user