mirror of
https://github.com/kuhyx/screen-locker.git
synced 2026-11-10 20:27:13 +01:00
Sync the workout log across devices using the shared crdt-sync / crdt_sync_dart CRDT transport (same scheme as diet_guard). - Python: new _workout_sync.py + _temperature_status_mixin.py; wire sync into screen_lock.py / status_view.py; add the crdt-sync git dependency and test_sync_fixtures / test_workout_sync suites. - Dart (workout_app): new workout_sync_service.dart, github_device_auth.dart, sync_settings.dart with tests + fakes; settings/workout screens updated. - docs: workstream-d-shared-crdt-transport.md. Verification: pytest 747 passed at 100% coverage; flutter analyze clean; flutter test passed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RRCdR4D8SaVrN2xraMQxM
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
"""Isolation fixture for the phone-workout GitHub sync token.
|
|
|
|
Split out of ``conftest.py`` (already at the repo's 400-line-per-file cap)
|
|
and re-exported there so pytest still picks this up as an autouse fixture
|
|
for every test in this directory.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
if TYPE_CHECKING:
|
|
from collections.abc import Iterator
|
|
from pathlib import Path
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def isolate_sync_token(tmp_path: Path) -> Iterator[None]:
|
|
"""Redirect SYNC_TOKEN_FILE to tmp_path so tests never see a real token.
|
|
|
|
Without this, any test calling ``_verify_phone_workout`` would fall
|
|
through to ``pull_synced_workout()``, which -- if a real
|
|
``~/.config/screen_locker/sync_token`` happens to exist on the host --
|
|
would make a real GitHub API call. Defaulting to a nonexistent tmp_path
|
|
file makes ``read_sync_token()`` return None, the same benign "sync not
|
|
configured" state every existing test already assumes.
|
|
"""
|
|
with patch(
|
|
"screen_locker._workout_sync.SYNC_TOKEN_FILE",
|
|
tmp_path / "sync_token",
|
|
):
|
|
yield
|