feat: add resumable per-user sync pipeline
This commit is contained in:
30
tests/sync/fakes.py
Normal file
30
tests/sync/fakes.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from app.garmin.uploader import UploadResult
|
||||
|
||||
|
||||
class FakeMyWhooshClient:
|
||||
def __init__(self, activities, fit_bytes: bytes) -> None:
|
||||
self.activities = activities
|
||||
self.fit_bytes = fit_bytes
|
||||
self.list_calls = 0
|
||||
self.download_calls = 0
|
||||
|
||||
async def list_activities(self, email: str, password: str):
|
||||
self.list_calls += 1
|
||||
return list(self.activities)
|
||||
|
||||
async def download_fit(self, activity_file_id: str, email: str, password: str) -> bytes:
|
||||
self.download_calls += 1
|
||||
return self.fit_bytes
|
||||
|
||||
|
||||
class FakeGarminUploader:
|
||||
def __init__(self, result: UploadResult | None = None, error: Exception | None = None) -> None:
|
||||
self.result = result or UploadResult("imported", False, "g-1", {"activityId": "g-1"})
|
||||
self.error = error
|
||||
self.calls = 0
|
||||
|
||||
def import_fit(self, fit_path, mfa_code=None):
|
||||
self.calls += 1
|
||||
if self.error is not None:
|
||||
raise self.error
|
||||
return self.result
|
||||
Reference in New Issue
Block a user