mirror of
https://github.com/kuhyx/screen-locker.git
synced 2026-11-10 20:07:16 +01:00
The PC push aborted before it ever tried Firebase whenever the GitHub PAT
was missing ("Workouts NOT synced: no sync token"), so once the PAT was lost
this machine published nothing although Firebase was configured and live.
The phone has not written the GitHub repo since 2026-08-21.
- sync_client() / sync_client_or_reason(): firebase_client_for("screen_locker")
only, proven with can_access_remote(), healed once from a sibling app's
session, else a warning naming what will not sync (push AND pull) plus a
recorded degraded source. No config -> warning, no fallback.
- _manual_push and scripts/tombstone_sync_record.py take their client from
sync_client_or_reason(); the push result carries the reason.
- Deleted: read_sync_token, remote_client, the mirror client, _push_outcome
(the half-landed-push case no longer exists), SYNC_TOKEN_FILE and
SYNC_REPO_OWNER/NAME, the sync_token test fixture. Status backend is
"firebase" or "none".
- crdt-sync pinned to v0.9.2 in pyproject, requirements.txt and
install_systemd.sh (the installer still said v0.9.0).
kuhyx/syncs/screen-locker-sync is left untouched as an archive; no code
reads it.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018RHwVPyiiQMPh4M3JQwQku
47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
"""Autouse isolation fixtures for the phone-workout sync layer.
|
|
|
|
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_device_id(tmp_path: Path) -> Iterator[None]:
|
|
"""Redirect the persisted device id so tests never mint one for real.
|
|
|
|
Without this the first test that syncs writes a uuid into the real
|
|
``~/.local/share/screen_locker/.device_id``, and this machine's live sync
|
|
identity ends up decided by whichever test happened to run first.
|
|
"""
|
|
with patch(
|
|
"screen_locker._device.SYNC_DEVICE_ID_FILE",
|
|
tmp_path / ".device_id",
|
|
):
|
|
yield
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def no_sync_retry_sleep() -> Iterator[None]:
|
|
"""Make the sync retry's backoff instant for every test.
|
|
|
|
``with_sync_retry`` waits 2s + 4s + 8s before giving up, which is right in
|
|
production (it covers the network coming up after boot/resume) but would
|
|
add ~14s to every test that exercises a sync failure. Tests that care about
|
|
the backoff assert on the patched ``sleep`` calls instead -- see
|
|
``test_sync_retry.py``.
|
|
"""
|
|
with patch("screen_locker._sync_retry.sleep"):
|
|
yield
|