mirror of
https://github.com/kuhyx/screen-locker.git
synced 2026-11-10 20:47:14 +01:00
Check Phone only ever checked today's date, so a verified workout from earlier in the week (e.g. yesterday's run, found once the phone connects later) was never backfilled unless you ran the --status CLI. It now falls back to the existing RunnerUp week-scanner plus a new StrongLifts equivalent, still pulling and validating the real file via ADB before crediting anything. GPS distance tracking undershoots on tight turns/tree cover, so a run within 5% of the 5.0 km minimum (e.g. 4.9 km) is now accepted instead of silently rejected — duration is clock-based and gets no such leeway. Also fixes a pre-existing bug in the --status CLI surfaced by this change: its weekly-total summary derived counts from a per-day checkmark (max 1 per day) instead of screen_locker._weekly_check.count_weekly_workouts, undercounting any day with more than one verified workout. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ERWuV1nExiMfiNb9Gb7AQt
51 lines
1.9 KiB
Python
51 lines
1.9 KiB
Python
"""Tests for status_view.py: Check Phone's week-scan backfill reporting."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
from screen_locker._status_view_verify import PhoneCheckOutcome
|
|
from screen_locker.tests._status_view_helpers import _make_window, _snapshot
|
|
|
|
|
|
class TestPollRoutesPhoneCheckOutcome:
|
|
def test_poll_routes_to_result_when_future_done(self, mock_tk: MagicMock) -> None:
|
|
window = _make_window(mock_tk, _snapshot())
|
|
mock_future = MagicMock()
|
|
mock_future.done.return_value = True
|
|
mock_future.result.return_value = PhoneCheckOutcome(
|
|
"phone_verified", "verified", "ok", None
|
|
)
|
|
window._phone_future = mock_future
|
|
with patch.object(window, "_on_phone_check_result") as mock_handle:
|
|
window._poll_phone_check()
|
|
mock_handle.assert_called_once_with(mock_future.result.return_value)
|
|
|
|
|
|
class TestWeekScanBackfillResult:
|
|
def test_week_scan_backfill_shows_fill_message_and_applies_no_credit(
|
|
self, mock_tk: MagicMock
|
|
) -> None:
|
|
"""A week-scan backfill message is shown as-is, no _apply_workout_credit call."""
|
|
fake_verifier = MagicMock()
|
|
window = _make_window(
|
|
mock_tk,
|
|
_snapshot(),
|
|
verifier_factory=lambda _log_file: fake_verifier,
|
|
)
|
|
with patch(
|
|
"screen_locker._status_view_verify.gather_status", return_value=_snapshot()
|
|
):
|
|
window._on_phone_check_result(
|
|
PhoneCheckOutcome(
|
|
None,
|
|
"not_verified",
|
|
"no lifts",
|
|
"no run",
|
|
"Auto-filled 1 workout from earlier this week.",
|
|
)
|
|
)
|
|
assert window._credit_message == "Auto-filled 1 workout from earlier this week."
|
|
assert window._phone_check_result is None
|
|
fake_verifier._apply_workout_credit.assert_not_called()
|