mirror of
https://github.com/kuhyx/screen-locker.git
synced 2026-11-29 14:53:22 +01:00
Compare commits
No commits in common. "8df1ff6d09959f75eb31d3bac539c5c10fa8492d" and "ae7566628c50f3015eeab74c4a0ed78f16a20230" have entirely different histories.
8df1ff6d09
...
ae7566628c
@ -12,14 +12,6 @@ each further one +1h, and an accepted LeetCode submission that day +1h (flat,
|
|||||||
read from leetcode-guard's ledger, once per day). The config is re-derived from
|
read from leetcode-guard's ledger, once per day). The config is re-derived from
|
||||||
those sources on each new day, so nothing has to be "remembered" across reboots.
|
those sources on each new day, so nothing has to be "remembered" across reboots.
|
||||||
|
|
||||||
A RunnerUp run is credited from its TCX export, found in the WebDAV drop
|
|
||||||
directory RunnerUp uploads to on this machine (`~/data/cloud/RunnerUp/`, plus
|
|
||||||
`processed/` once endurain-import has taken it) or, when a phone is adb-visible,
|
|
||||||
in `/sdcard/Documents/RunnerUp/`. The 15-minute `workout-sync.timer` scans both,
|
|
||||||
so a run finished after 20:00 pushes the hour later without the phone being
|
|
||||||
plugged in; the per-minute shutdown check then lifts the night lockdown on its
|
|
||||||
own once the hour is past "now" (digital-wellbeing's check script).
|
|
||||||
|
|
||||||
## MCP server (Claude Code integration)
|
## MCP server (Claude Code integration)
|
||||||
|
|
||||||
screen-locker exposes a **read-only** MCP server (`screen_locker._mcp`) so
|
screen-locker exposes a **read-only** MCP server (`screen_locker._mcp`) so
|
||||||
|
|||||||
@ -19,5 +19,5 @@ pytest-xdist==3.8.0
|
|||||||
# token over the REST endpoint; crdt-sync already pulls requests in, but this
|
# token over the REST endpoint; crdt-sync already pulls requests in, but this
|
||||||
# module imports it itself, so it is declared rather than assumed.
|
# module imports it itself, so it is declared rather than assumed.
|
||||||
requests==2.34.2
|
requests==2.34.2
|
||||||
ruff==0.16.8
|
ruff==0.16.7
|
||||||
types-requests==2.33.0.20260906
|
types-requests==2.33.0.20260906
|
||||||
|
|||||||
@ -4,13 +4,6 @@ Neither early_bird (a same-day pending marker, see ``_early_bird.py``) nor
|
|||||||
sick_day (tracked in ``sick_history.json`` via ``_sick_tracker.py``) live in
|
sick_day (tracked in ``sick_history.json`` via ``_sick_tracker.py``) live in
|
||||||
log.json — this module only checks their pending state and, on
|
log.json — this module only checks their pending state and, on
|
||||||
success, writes the *real* outcome (phone_verified/runnerup_verified) there.
|
success, writes the *real* outcome (phone_verified/runnerup_verified) there.
|
||||||
|
|
||||||
The upgrade credits through ``_apply_workout_credit`` -- save first, reward
|
|
||||||
only if the entry was actually appended. It used to push the shutdown hour
|
|
||||||
and THEN save: when the same run was already in the log (the 15-minute sync
|
|
||||||
pass had pulled the TCX at 20:25 on 2026-09-16) the save deduped to nothing
|
|
||||||
and the +2h landed anyway, and again on every 5-minute tick while the
|
|
||||||
pending marker lasted -- a runaway that only the 23:00 ceiling stopped.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
@ -163,7 +156,8 @@ class AutoUpgradeMixin(_ReasonsMixin):
|
|||||||
self.workout_data["type"] = "phone_verified"
|
self.workout_data["type"] = "phone_verified"
|
||||||
self.workout_data["source"] = message
|
self.workout_data["source"] = message
|
||||||
self.workout_data["after_sick_day"] = "true"
|
self.workout_data["after_sick_day"] = "true"
|
||||||
self._apply_workout_credit()
|
self._adjust_shutdown_time_later()
|
||||||
|
self.save_workout_log()
|
||||||
return True
|
return True
|
||||||
_logger.info("Auto-upgrade phone skipped (%s), trying RunnerUp...", status)
|
_logger.info("Auto-upgrade phone skipped (%s), trying RunnerUp...", status)
|
||||||
try:
|
try:
|
||||||
@ -183,7 +177,8 @@ class AutoUpgradeMixin(_ReasonsMixin):
|
|||||||
self.workout_data["type"] = "runnerup_verified"
|
self.workout_data["type"] = "runnerup_verified"
|
||||||
self.workout_data["source"] = runnerup_msg
|
self.workout_data["source"] = runnerup_msg
|
||||||
self.workout_data["after_sick_day"] = "true"
|
self.workout_data["after_sick_day"] = "true"
|
||||||
self._apply_workout_credit()
|
self._adjust_shutdown_time_later()
|
||||||
|
self.save_workout_log()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _try_auto_upgrade_early_bird(self) -> bool:
|
def _try_auto_upgrade_early_bird(self) -> bool:
|
||||||
@ -201,7 +196,8 @@ class AutoUpgradeMixin(_ReasonsMixin):
|
|||||||
self.workout_data["type"] = "phone_verified"
|
self.workout_data["type"] = "phone_verified"
|
||||||
self.workout_data["source"] = message
|
self.workout_data["source"] = message
|
||||||
self.workout_data["after_early_bird"] = "true"
|
self.workout_data["after_early_bird"] = "true"
|
||||||
self._apply_workout_credit()
|
self._adjust_shutdown_time_later()
|
||||||
|
self.save_workout_log()
|
||||||
return True
|
return True
|
||||||
_logger.info("Early bird phone skipped (%s), trying RunnerUp...", status)
|
_logger.info("Early bird phone skipped (%s), trying RunnerUp...", status)
|
||||||
try:
|
try:
|
||||||
@ -222,5 +218,6 @@ class AutoUpgradeMixin(_ReasonsMixin):
|
|||||||
self.workout_data["type"] = "runnerup_verified"
|
self.workout_data["type"] = "runnerup_verified"
|
||||||
self.workout_data["source"] = runnerup_msg
|
self.workout_data["source"] = runnerup_msg
|
||||||
self.workout_data["after_early_bird"] = "true"
|
self.workout_data["after_early_bird"] = "true"
|
||||||
self._apply_workout_credit()
|
self._adjust_shutdown_time_later()
|
||||||
|
self.save_workout_log()
|
||||||
return True
|
return True
|
||||||
|
|||||||
@ -143,17 +143,6 @@ RUNNERUP_EXPORT_DIRS: tuple[str, ...] = (
|
|||||||
"/storage/emulated/0/Documents/RunnerUp",
|
"/storage/emulated/0/Documents/RunnerUp",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Where RunnerUp's WebDAV synchroniser drops the same exports on this machine
|
|
||||||
# (dufs, see ~/src/dufs-cloud), and where endurain-import moves them once
|
|
||||||
# Endurain has them. Read straight off the disk, so a run is credited without
|
|
||||||
# the phone being adb-reachable -- on 2026-09-16 the TCX landed here at 20:08
|
|
||||||
# and the phone was only plugged in at 20:25. Same filenames as the phone
|
|
||||||
# export, optionally prefixed with the device name (RunnerUp_Pixel_6a_...).
|
|
||||||
RUNNERUP_WEBDAV_DIRS: tuple[Path, ...] = (
|
|
||||||
Path.home() / "data" / "cloud" / "RunnerUp",
|
|
||||||
Path.home() / "data" / "cloud" / "RunnerUp" / "processed",
|
|
||||||
)
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Sync (phone workout data) — Workstream C, built on the shared crdt-sync
|
# Sync (phone workout data) — Workstream C, built on the shared crdt-sync
|
||||||
# library. GitHub is used purely as dumb file storage via the REST Contents
|
# library. GitHub is used purely as dumb file storage via the REST Contents
|
||||||
|
|||||||
@ -17,25 +17,15 @@ from typing import TYPE_CHECKING
|
|||||||
from screen_locker._log_mixin import write_signed_entry
|
from screen_locker._log_mixin import write_signed_entry
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from collections.abc import Callable
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# Same shape as ``_manual_sync.OnIngestedCallback``: the appended
|
|
||||||
# ``workout_data`` and that day's entries *before* it.
|
|
||||||
OnIngestedCallback = Callable[[dict, "list[dict]"], None]
|
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class RunnerUpBackfillMixin:
|
class RunnerUpBackfillMixin:
|
||||||
"""Fills the log from RunnerUp exports for a date or a whole week."""
|
"""Fills the log from RunnerUp exports for a date or a whole week."""
|
||||||
|
|
||||||
def _try_fill_runnerup_for_date(
|
def _try_fill_runnerup_for_date(self, date_str: str, log_file: Path) -> bool:
|
||||||
self,
|
|
||||||
date_str: str,
|
|
||||||
log_file: Path,
|
|
||||||
on_ingested: OnIngestedCallback | None = None,
|
|
||||||
) -> bool:
|
|
||||||
"""Append a verified RunnerUp entry for ``date_str`` if not already logged.
|
"""Append a verified RunnerUp entry for ``date_str`` if not already logged.
|
||||||
|
|
||||||
Appends via the write chokepoint, which dedups by ``workout_id``
|
Appends via the write chokepoint, which dedups by ``workout_id``
|
||||||
@ -43,14 +33,6 @@ class RunnerUpBackfillMixin:
|
|||||||
recorded is a no-op, but a day that only holds, say, a manual workout
|
recorded is a no-op, but a day that only holds, say, a manual workout
|
||||||
still gets the run appended alongside it (multiple workouts per day).
|
still gets the run appended alongside it (multiple workouts per day).
|
||||||
|
|
||||||
``on_ingested(workout_data, prior_entries)`` fires once per appended
|
|
||||||
entry, exactly like manual-sync ingestion, so a run pulled off the
|
|
||||||
phone earns the same day-scaled reward as every other source. It used
|
|
||||||
to earn only a weekly-surplus bonus (+1h per workout above the weekly
|
|
||||||
minimum), which is 0 for most of the week: on 2026-09-16 a run synced
|
|
||||||
at 20:25 left the config at 20:00 while the daily reset would have
|
|
||||||
derived 22:00 from the same log.
|
|
||||||
|
|
||||||
Returns True if a new verified entry was appended for ``date_str``.
|
Returns True if a new verified entry was appended for ``date_str``.
|
||||||
"""
|
"""
|
||||||
for remote in self._find_runnerup_exports_for_date(date_str):
|
for remote in self._find_runnerup_exports_for_date(date_str):
|
||||||
@ -73,30 +55,20 @@ class RunnerUpBackfillMixin:
|
|||||||
"distance_km": round(data["distance_m"] / 1000, 2),
|
"distance_km": round(data["distance_m"] / 1000, 2),
|
||||||
"duration_minutes": round(data["duration_seconds"] / 60, 1),
|
"duration_minutes": round(data["duration_seconds"] / 60, 1),
|
||||||
}
|
}
|
||||||
result = write_signed_entry(log_file, date_str, workout_data)
|
if write_signed_entry(log_file, date_str, workout_data).appended:
|
||||||
if not result.appended:
|
_logger.info("Auto-filled RunnerUp entry for %s: %s", date_str, msg)
|
||||||
return False
|
return True
|
||||||
_logger.info("Auto-filled RunnerUp entry for %s: %s", date_str, msg)
|
return False
|
||||||
if on_ingested is not None:
|
|
||||||
on_ingested(workout_data, result.prior_entries)
|
|
||||||
return True
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _scan_and_fill_week_runnerup(
|
def _scan_and_fill_week_runnerup(self, log_file: Path) -> int:
|
||||||
self, log_file: Path, on_ingested: OnIngestedCallback | None = None
|
|
||||||
) -> int:
|
|
||||||
"""Scan the current ISO week for RunnerUp runs and append any not logged.
|
"""Scan the current ISO week for RunnerUp runs and append any not logged.
|
||||||
|
|
||||||
``on_ingested`` is passed through to every appended entry; see
|
Returns the count of newly appended entries (0 if phone not connected).
|
||||||
:meth:`_try_fill_runnerup_for_date`.
|
|
||||||
|
|
||||||
Returns the count of newly appended entries (0 if no export source --
|
|
||||||
neither the WebDAV drop directory nor an adb-visible phone).
|
|
||||||
"""
|
"""
|
||||||
if not self._has_runnerup_source():
|
if not self._has_adb_device():
|
||||||
_logger.info(
|
_logger.info(
|
||||||
"No RunnerUp source (no WebDAV drop dir, phone not connected); "
|
"Phone not connected; skipping auto-scan for past RunnerUp exports."
|
||||||
"skipping auto-scan for past RunnerUp exports."
|
|
||||||
)
|
)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@ -107,9 +79,7 @@ class RunnerUpBackfillMixin:
|
|||||||
filled = 0
|
filled = 0
|
||||||
current = week_start
|
current = week_start
|
||||||
while current <= today:
|
while current <= today:
|
||||||
if self._try_fill_runnerup_for_date(
|
if self._try_fill_runnerup_for_date(current.strftime("%Y-%m-%d"), log_file):
|
||||||
current.strftime("%Y-%m-%d"), log_file, on_ingested
|
|
||||||
):
|
|
||||||
filled += 1
|
filled += 1
|
||||||
current += timedelta(days=1)
|
current += timedelta(days=1)
|
||||||
|
|
||||||
|
|||||||
@ -41,15 +41,7 @@ class RunnerUpTcxMixin:
|
|||||||
"""Pulls and parses RunnerUp's TCX exports over adb."""
|
"""Pulls and parses RunnerUp's TCX exports over adb."""
|
||||||
|
|
||||||
def _pull_and_parse_tcx(self, remote_path: str) -> dict[str, Any] | None:
|
def _pull_and_parse_tcx(self, remote_path: str) -> dict[str, Any] | None:
|
||||||
"""Parse a TCX export, pulling it over adb first unless it is local.
|
"""Pull a remote TCX file and parse it. Returns activity dict or None."""
|
||||||
|
|
||||||
A path that exists on this machine (the WebDAV drop directory, see
|
|
||||||
``RUNNERUP_WEBDAV_DIRS``) is parsed in place; anything else is a
|
|
||||||
phone path and goes through ``adb pull``. Returns the activity dict
|
|
||||||
or None.
|
|
||||||
"""
|
|
||||||
if Path(remote_path).is_file():
|
|
||||||
return self._parse_tcx(remote_path)
|
|
||||||
tmp_dir = tempfile.mkdtemp(prefix="runnerup_tcx_")
|
tmp_dir = tempfile.mkdtemp(prefix="runnerup_tcx_")
|
||||||
local_path = str(Path(tmp_dir) / "activity.tcx")
|
local_path = str(Path(tmp_dir) / "activity.tcx")
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -15,7 +15,6 @@ from screen_locker._constants import (
|
|||||||
MIN_WORKOUT_DURATION_MINUTES,
|
MIN_WORKOUT_DURATION_MINUTES,
|
||||||
RUNNERUP_DISTANCE_TOLERANCE,
|
RUNNERUP_DISTANCE_TOLERANCE,
|
||||||
RUNNERUP_EXPORT_DIRS,
|
RUNNERUP_EXPORT_DIRS,
|
||||||
RUNNERUP_WEBDAV_DIRS,
|
|
||||||
WORKOUT_DURATION_ACCEPT_MINUTES,
|
WORKOUT_DURATION_ACCEPT_MINUTES,
|
||||||
)
|
)
|
||||||
from screen_locker._day import today_str
|
from screen_locker._day import today_str
|
||||||
@ -51,43 +50,14 @@ class RunnerUpVerificationMixin(
|
|||||||
# File-based path (no root required)
|
# File-based path (no root required)
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
def _has_runnerup_source(self) -> bool:
|
|
||||||
"""Whether any RunnerUp export source is reachable right now.
|
|
||||||
|
|
||||||
The WebDAV drop directory on this disk counts as much as an
|
|
||||||
adb-visible phone: both hold the same TCX files.
|
|
||||||
"""
|
|
||||||
return self._has_local_runnerup_dir() or self._has_adb_device()
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _has_local_runnerup_dir() -> bool:
|
|
||||||
return any(d.is_dir() for d in RUNNERUP_WEBDAV_DIRS)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _find_local_runnerup_exports_for_date(date_str: str) -> list[str]:
|
|
||||||
"""TCX files for ``date_str`` in the WebDAV drop directories, sorted."""
|
|
||||||
found: list[str] = []
|
|
||||||
for local_dir in RUNNERUP_WEBDAV_DIRS:
|
|
||||||
if not local_dir.is_dir():
|
|
||||||
continue
|
|
||||||
for path in sorted(local_dir.glob("*.tcx")):
|
|
||||||
if date_str in path.name and str(path) not in found:
|
|
||||||
found.append(str(path))
|
|
||||||
return found
|
|
||||||
|
|
||||||
def _find_runnerup_exports_for_date(self, date_str: str) -> list[str]:
|
def _find_runnerup_exports_for_date(self, date_str: str) -> list[str]:
|
||||||
"""Return paths of RunnerUp TCX exports for the given date, or empty list.
|
"""Return adb paths of RunnerUp TCX exports for the given date, or empty list.
|
||||||
|
|
||||||
Local WebDAV copies come first (no phone needed), then the phone's
|
|
||||||
export directories over adb when a device is attached.
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
date_str: ISO date string in ``YYYY-MM-DD`` format matched against
|
date_str: ISO date string in ``YYYY-MM-DD`` format matched against
|
||||||
TCX filenames (``RunnerUp_YYYY-MM-DD-HH-MM-SS_xxx.tcx``).
|
TCX filenames (``RunnerUp_YYYY-MM-DD-HH-MM-SS_xxx.tcx``).
|
||||||
"""
|
"""
|
||||||
found = self._find_local_runnerup_exports_for_date(date_str)
|
found: list[str] = []
|
||||||
if not self._has_adb_device():
|
|
||||||
return found
|
|
||||||
for dirpath in RUNNERUP_EXPORT_DIRS:
|
for dirpath in RUNNERUP_EXPORT_DIRS:
|
||||||
ok, out = self._run_adb(["shell", "ls", dirpath])
|
ok, out = self._run_adb(["shell", "ls", dirpath])
|
||||||
if not ok or not out.strip():
|
if not ok or not out.strip():
|
||||||
@ -195,13 +165,13 @@ class RunnerUpVerificationMixin(
|
|||||||
if not skew_ok:
|
if not skew_ok:
|
||||||
return "clock_tampered", skew_msg
|
return "clock_tampered", skew_msg
|
||||||
|
|
||||||
if not self._has_runnerup_source():
|
if not self._has_adb_device():
|
||||||
return (
|
return (
|
||||||
"no_phone",
|
"no_phone",
|
||||||
"Phone not connected — plug in via USB or enable wireless ADB",
|
"Phone not connected — plug in via USB or enable wireless ADB",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Path 1: file-based (no root needed; WebDAV copies first, then adb).
|
# Path 1: file-based (no root needed).
|
||||||
file_result = self._verify_runnerup_via_files()
|
file_result = self._verify_runnerup_via_files()
|
||||||
if file_result is not None:
|
if file_result is not None:
|
||||||
_logger.info("RunnerUp file-based result: %s", file_result[0])
|
_logger.info("RunnerUp file-based result: %s", file_result[0])
|
||||||
@ -209,11 +179,5 @@ class RunnerUpVerificationMixin(
|
|||||||
|
|
||||||
# Path 2: root DB pull (fallback when no export files found yet).
|
# Path 2: root DB pull (fallback when no export files found yet).
|
||||||
# On a non-rooted device this path cannot succeed; _verify_runnerup_via_db
|
# On a non-rooted device this path cannot succeed; _verify_runnerup_via_db
|
||||||
# reports that plainly rather than as a generic failure. Needs adb.
|
# reports that plainly rather than as a generic failure.
|
||||||
if not self._has_adb_device():
|
|
||||||
return (
|
|
||||||
"not_verified",
|
|
||||||
f"No RunnerUp export for today in {RUNNERUP_WEBDAV_DIRS} and the "
|
|
||||||
"phone is not adb-reachable",
|
|
||||||
)
|
|
||||||
return self._verify_runnerup_via_db()
|
return self._verify_runnerup_via_db()
|
||||||
|
|||||||
@ -95,19 +95,18 @@ def run_status(locker: ScreenLocker) -> None:
|
|||||||
# which would undercount a day holding two verified workouts.
|
# which would undercount a day holding two verified workouts.
|
||||||
before_count = count_weekly_workouts(log_file)
|
before_count = count_weekly_workouts(log_file)
|
||||||
|
|
||||||
# RunnerUp scan. Each fill is credited by the shared ingestion callback
|
# RunnerUp scan
|
||||||
# (+2h first counted workout of its day, +1h each further one), the same
|
n_filled = locker._scan_and_fill_week_runnerup(log_file)
|
||||||
# rule the timer's sync pass and the daily base reset use.
|
|
||||||
n_filled = locker._scan_and_fill_week_runnerup(
|
|
||||||
log_file, on_ingested=locker._credit_ingested_workout
|
|
||||||
)
|
|
||||||
locker.workout_data = {}
|
|
||||||
if n_filled > 0:
|
if n_filled > 0:
|
||||||
print(f" Auto-filled {n_filled} workout(s) from RunnerUp exports.")
|
print(f" Auto-filled {n_filled} workout(s) from RunnerUp exports.")
|
||||||
after_count = count_weekly_workouts(log_file)
|
after_count = count_weekly_workouts(log_file)
|
||||||
_, mw_hour, _ = locker._read_shutdown_config() or (None, None, None)
|
bonus = max(0, after_count - max(WEEKLY_WORKOUT_MINIMUM, before_count))
|
||||||
if mw_hour is not None:
|
if bonus > 0:
|
||||||
print(f" Shutdown tonight: {mw_hour:02d}:00.")
|
ok = locker._adjust_shutdown_time_by(bonus)
|
||||||
|
if ok:
|
||||||
|
print(f" +{bonus}h shutdown bonus applied.")
|
||||||
|
else:
|
||||||
|
print(f" +{bonus}h shutdown bonus pending (config write failed).")
|
||||||
else:
|
else:
|
||||||
print(" No new workouts found via RunnerUp scan.")
|
print(" No new workouts found via RunnerUp scan.")
|
||||||
after_count = before_count
|
after_count = before_count
|
||||||
|
|||||||
@ -59,34 +59,24 @@ def _make_bare_verifier(log_file: Path) -> ScreenLocker:
|
|||||||
def _backfill_week_and_apply_bonus(verifier: ScreenLocker) -> str | None:
|
def _backfill_week_and_apply_bonus(verifier: ScreenLocker) -> str | None:
|
||||||
"""Scan the current week for unlogged RunnerUp/StrongLifts and credit it.
|
"""Scan the current week for unlogged RunnerUp/StrongLifts and credit it.
|
||||||
|
|
||||||
Each RunnerUp fill is credited through the same ``on_ingested`` callback
|
Reuses the exact prev/new-count + ``_adjust_shutdown_time_by`` bonus
|
||||||
as the timer's sync pass and every other ingestion source
|
pattern already proven by the automatic lock-check
|
||||||
(``_sync_mixin._credit_ingested_workout``): +2h for the first counted
|
(``screen_lock.py:_auto_fill_week_runnerup_bonus``) and the ``--status``
|
||||||
workout of its day, +1h for each further one. The callback files the
|
CLI (``_status.py``) — deliberately *not* routed through
|
||||||
reward against the entry's OWN day, so a back-dated fill is not mis-dated
|
``_apply_workout_credit``, which always files under today by design and
|
||||||
the way routing it through ``_apply_workout_credit`` (always today) would.
|
would mis-date a backfilled entry.
|
||||||
|
|
||||||
The StrongLifts fill keeps the weekly-surplus rule for now (+1h per
|
|
||||||
workout above the weekly minimum); it is a separate source with its own
|
|
||||||
dedup and is out of scope for the RunnerUp credit fix.
|
|
||||||
|
|
||||||
Returns a human-readable summary if anything was filled, else ``None``.
|
Returns a human-readable summary if anything was filled, else ``None``.
|
||||||
"""
|
"""
|
||||||
prev_count = count_weekly_workouts(verifier.log_file)
|
prev_count = count_weekly_workouts(verifier.log_file)
|
||||||
filled = verifier._scan_and_fill_week_runnerup(
|
filled = verifier._scan_and_fill_week_runnerup(verifier.log_file)
|
||||||
verifier.log_file, on_ingested=verifier._credit_ingested_workout
|
filled += verifier._try_fill_stronglifts_for_week(verifier.log_file)
|
||||||
)
|
|
||||||
verifier.workout_data = {}
|
|
||||||
sl_filled = verifier._try_fill_stronglifts_for_week(verifier.log_file)
|
|
||||||
bonus = 0
|
|
||||||
if sl_filled:
|
|
||||||
new_count = count_weekly_workouts(verifier.log_file)
|
|
||||||
bonus = max(0, new_count - max(WEEKLY_WORKOUT_MINIMUM, prev_count + filled))
|
|
||||||
if bonus > 0:
|
|
||||||
verifier._adjust_shutdown_time_by(bonus)
|
|
||||||
filled += sl_filled
|
|
||||||
if not filled:
|
if not filled:
|
||||||
return None
|
return None
|
||||||
|
new_count = count_weekly_workouts(verifier.log_file)
|
||||||
|
bonus = max(0, new_count - max(WEEKLY_WORKOUT_MINIMUM, prev_count))
|
||||||
|
if bonus > 0:
|
||||||
|
verifier._adjust_shutdown_time_by(bonus)
|
||||||
plural = "workout" if filled == 1 else "workouts"
|
plural = "workout" if filled == 1 else "workouts"
|
||||||
message = f"Auto-filled {filled} {plural} from earlier this week."
|
message = f"Auto-filled {filled} {plural} from earlier this week."
|
||||||
if bonus > 0:
|
if bonus > 0:
|
||||||
|
|||||||
@ -16,6 +16,10 @@ from screen_locker._manual_push import push_pc_workouts
|
|||||||
from screen_locker._manual_sync import ingest_manual_records
|
from screen_locker._manual_sync import ingest_manual_records
|
||||||
from screen_locker._session_sync import ingest_session_records
|
from screen_locker._session_sync import ingest_session_records
|
||||||
from screen_locker._shutdown_base import apply_leetcode_bonus_if_new
|
from screen_locker._shutdown_base import apply_leetcode_bonus_if_new
|
||||||
|
from screen_locker._weekly_check import (
|
||||||
|
WEEKLY_WORKOUT_MINIMUM,
|
||||||
|
count_weekly_workouts,
|
||||||
|
)
|
||||||
from screen_locker._workout_sync import (
|
from screen_locker._workout_sync import (
|
||||||
pull_all_manual_records,
|
pull_all_manual_records,
|
||||||
pull_all_session_records,
|
pull_all_session_records,
|
||||||
@ -63,7 +67,7 @@ class SyncMixin:
|
|||||||
ingested = ingest_manual_records(
|
ingested = ingest_manual_records(
|
||||||
self.log_file,
|
self.log_file,
|
||||||
pull_all_manual_records(),
|
pull_all_manual_records(),
|
||||||
on_ingested=self._credit_ingested_workout,
|
on_ingested=self._credit_ingested_manual_workout,
|
||||||
)
|
)
|
||||||
for record_id in ingested:
|
for record_id in ingested:
|
||||||
_logger.info("Ingested synced manual workout: %s", record_id)
|
_logger.info("Ingested synced manual workout: %s", record_id)
|
||||||
@ -84,51 +88,42 @@ class SyncMixin:
|
|||||||
ingested = ingest_session_records(
|
ingested = ingest_session_records(
|
||||||
self.log_file,
|
self.log_file,
|
||||||
pull_all_session_records(),
|
pull_all_session_records(),
|
||||||
on_ingested=self._credit_ingested_workout,
|
on_ingested=self._credit_ingested_manual_workout,
|
||||||
)
|
)
|
||||||
for record_id in ingested:
|
for record_id in ingested:
|
||||||
_logger.info("Ingested synced StrongLifts session: %s", record_id)
|
_logger.info("Ingested synced StrongLifts session: %s", record_id)
|
||||||
self.workout_data = {}
|
self.workout_data = {}
|
||||||
|
|
||||||
def _credit_ingested_workout(
|
def _credit_ingested_manual_workout(
|
||||||
self, entry: dict[str, str], prior_entries: list[dict]
|
self, entry: dict[str, str], prior_entries: list[dict]
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Apply the live-workout reward to a workout ingested from another source.
|
"""Apply the live-workout reward to a manual workout ingested via sync."""
|
||||||
|
|
||||||
Shared by manual-workout sync, StrongLifts session sync and the
|
|
||||||
RunnerUp TCX backfill -- one reward rule for every non-interactive way
|
|
||||||
a workout can land in the log.
|
|
||||||
"""
|
|
||||||
self.workout_data = entry
|
self.workout_data = entry
|
||||||
credit = self._apply_credit_for_written_entry(prior_entries)
|
credit = self._apply_credit_for_written_entry(prior_entries)
|
||||||
if credit.shutdown_adjusted:
|
if credit.shutdown_adjusted:
|
||||||
_logger.info(
|
_logger.info(
|
||||||
"Ingested workout pushed shutdown time +2h: %s",
|
"Synced manual workout pushed shutdown time +2h: %s",
|
||||||
entry.get("source", ""),
|
entry.get("source", ""),
|
||||||
)
|
)
|
||||||
elif credit.extra_bonus_delta:
|
elif credit.extra_bonus_delta:
|
||||||
_logger.info(
|
_logger.info(
|
||||||
"Ingested workout added +%dh shutdown time: %s",
|
"Synced manual workout added +%dh shutdown time: %s",
|
||||||
credit.extra_bonus_delta,
|
credit.extra_bonus_delta,
|
||||||
entry.get("source", ""),
|
entry.get("source", ""),
|
||||||
)
|
)
|
||||||
|
|
||||||
def _auto_fill_week_runnerup_bonus(self) -> None:
|
def _auto_fill_week_runnerup_bonus(self) -> None:
|
||||||
"""Auto-fill missed RunnerUp workouts and credit each one.
|
"""Auto-fill missed RunnerUp workouts and award any earned bonus."""
|
||||||
|
prev_count = count_weekly_workouts(self.log_file)
|
||||||
Every appended run goes through the same
|
n_filled = self._scan_and_fill_week_runnerup(self.log_file)
|
||||||
:meth:`_credit_ingested_workout` callback as a synced manual workout
|
if not n_filled:
|
||||||
or StrongLifts session, so the reward is the documented day rule
|
return
|
||||||
(+2h first counted workout of its day, +1h each further one).
|
new_count = count_weekly_workouts(self.log_file)
|
||||||
"""
|
_logger.info("Auto-filled %d RunnerUp workout(s) from TCX exports.", n_filled)
|
||||||
n_filled = self._scan_and_fill_week_runnerup(
|
# Award +1h for each newly auto-filled workout above the minimum.
|
||||||
self.log_file, on_ingested=self._credit_ingested_workout
|
bonus = max(0, new_count - max(WEEKLY_WORKOUT_MINIMUM, prev_count))
|
||||||
)
|
if bonus > 0 and self._adjust_shutdown_time_by(bonus):
|
||||||
if n_filled:
|
_logger.info("Auto-fill extra bonus: +%dh shutdown time.", bonus)
|
||||||
_logger.info(
|
|
||||||
"Auto-filled %d RunnerUp workout(s) from TCX exports.", n_filled
|
|
||||||
)
|
|
||||||
self.workout_data = {}
|
|
||||||
|
|
||||||
def _apply_weekly_shutdown_bonus(self) -> None:
|
def _apply_weekly_shutdown_bonus(self) -> None:
|
||||||
"""Layer this week's earned shutdown bonus back on top of the fresh base."""
|
"""Layer this week's earned shutdown bonus back on top of the fresh base."""
|
||||||
|
|||||||
@ -32,7 +32,6 @@ def _make_locker(
|
|||||||
workout_data={},
|
workout_data={},
|
||||||
)
|
)
|
||||||
locker._scan_and_fill_week_runnerup = MagicMock(return_value=n_filled)
|
locker._scan_and_fill_week_runnerup = MagicMock(return_value=n_filled)
|
||||||
locker._credit_ingested_workout = MagicMock()
|
|
||||||
locker._adjust_shutdown_time_by = MagicMock(return_value=bonus_applied)
|
locker._adjust_shutdown_time_by = MagicMock(return_value=bonus_applied)
|
||||||
locker._read_shutdown_config = MagicMock(return_value=cfg)
|
locker._read_shutdown_config = MagicMock(return_value=cfg)
|
||||||
return locker
|
return locker
|
||||||
|
|||||||
@ -70,18 +70,3 @@ def _isolate_home(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Iterator[N
|
|||||||
monkeypatch.setenv("HOME", str(tmp_path))
|
monkeypatch.setenv("HOME", str(tmp_path))
|
||||||
with patch.object(Path, "home", lambda: tmp_path):
|
with patch.object(Path, "home", lambda: tmp_path):
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
|
||||||
def _no_real_runnerup_webdav_dir(tmp_path: Path) -> Iterator[None]:
|
|
||||||
"""Never let the RunnerUp scan read the developer's real WebDAV drop dir.
|
|
||||||
|
|
||||||
``RUNNERUP_WEBDAV_DIRS`` is bound from ``Path.home()`` at *import* time,
|
|
||||||
so ``_isolate_home`` cannot reach it. On this machine the real directory
|
|
||||||
holds today's run, which made every "phone absent → not verified" test
|
|
||||||
pass verification the day the source was added (2026-09-16). Tests that
|
|
||||||
want the local source point the tuple at directories they populate.
|
|
||||||
"""
|
|
||||||
absent = (tmp_path / "no-runnerup-webdav",)
|
|
||||||
with patch("screen_locker._runnerup_verification.RUNNERUP_WEBDAV_DIRS", absent):
|
|
||||||
yield
|
|
||||||
|
|||||||
@ -1,157 +0,0 @@
|
|||||||
"""The RunnerUp backfill credits each fill through the shared ``on_ingested``.
|
|
||||||
|
|
||||||
Regression for 2026-09-16: a run synced off the phone at 20:25 was appended
|
|
||||||
to the log but earned only the weekly-surplus bonus (+1h per workout above
|
|
||||||
the weekly minimum), which was 0 that early in the week -- the shutdown hour
|
|
||||||
stayed at 20:00 while the daily base reset would have derived 22:00 from the
|
|
||||||
very same log. Every fill now goes through the same credit callback as a
|
|
||||||
synced manual workout or StrongLifts session.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
from unittest.mock import MagicMock, patch
|
|
||||||
|
|
||||||
from screen_locker._log_io import load_workout_log
|
|
||||||
from screen_locker.tests.conftest import create_locker
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
_RUN = {"sport": 0, "duration_seconds": 4200, "distance_m": 5800}
|
|
||||||
|
|
||||||
|
|
||||||
def _stub_phone(locker: object, dates: set[str]) -> None:
|
|
||||||
"""Make the scan see one verified run on each of ``dates``."""
|
|
||||||
object.__setattr__(locker, "_has_adb_device", MagicMock(return_value=True))
|
|
||||||
object.__setattr__(
|
|
||||||
locker,
|
|
||||||
"_find_runnerup_exports_for_date",
|
|
||||||
MagicMock(side_effect=lambda d: ["/sdcard/run.tcx"] if d in dates else []),
|
|
||||||
)
|
|
||||||
object.__setattr__(locker, "_pull_and_parse_tcx", MagicMock(return_value=_RUN))
|
|
||||||
object.__setattr__(
|
|
||||||
locker, "_validate_runnerup_data", MagicMock(return_value=("verified", "ok"))
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class TestBackfillCreditCallback:
|
|
||||||
"""``_try_fill_runnerup_for_date`` / ``_scan_and_fill_week_runnerup``."""
|
|
||||||
|
|
||||||
def test_callback_gets_workout_data_and_prior_entries(
|
|
||||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
|
||||||
) -> None:
|
|
||||||
"""The callback sees the appended entry and that day's prior entries."""
|
|
||||||
locker = create_locker(mock_tk, tmp_path)
|
|
||||||
log_file = tmp_path / "log.json"
|
|
||||||
log_file.write_text(
|
|
||||||
'{"2026-09-16": [{"workout_data": {"type": "manual_workout"}}]}'
|
|
||||||
)
|
|
||||||
_stub_phone(locker, {"2026-09-16"})
|
|
||||||
seen: list[tuple[dict, list[dict]]] = []
|
|
||||||
|
|
||||||
with patch("screen_locker._log_mixin.compute_entry_hmac", return_value="sig"):
|
|
||||||
appended = locker._try_fill_runnerup_for_date(
|
|
||||||
"2026-09-16", log_file, lambda e, p: seen.append((e, p))
|
|
||||||
)
|
|
||||||
|
|
||||||
assert appended is True
|
|
||||||
assert len(seen) == 1
|
|
||||||
entry, prior = seen[0]
|
|
||||||
assert entry["type"] == "runnerup_verified"
|
|
||||||
assert entry["distance_km"] == 5.8
|
|
||||||
assert [e["workout_data"]["type"] for e in prior] == ["manual_workout"]
|
|
||||||
|
|
||||||
def test_duplicate_fill_does_not_fire_callback(
|
|
||||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
|
||||||
) -> None:
|
|
||||||
"""A re-scan of an already-logged run appends nothing and credits nothing."""
|
|
||||||
locker = create_locker(mock_tk, tmp_path)
|
|
||||||
log_file = tmp_path / "log.json"
|
|
||||||
log_file.write_text("{}")
|
|
||||||
_stub_phone(locker, {"2026-09-16"})
|
|
||||||
callback = MagicMock()
|
|
||||||
|
|
||||||
with patch("screen_locker._log_mixin.compute_entry_hmac", return_value="sig"):
|
|
||||||
first = locker._try_fill_runnerup_for_date("2026-09-16", log_file, callback)
|
|
||||||
second = locker._try_fill_runnerup_for_date(
|
|
||||||
"2026-09-16", log_file, callback
|
|
||||||
)
|
|
||||||
|
|
||||||
assert (first, second) == (True, False)
|
|
||||||
assert callback.call_count == 1
|
|
||||||
assert len(load_workout_log(log_file)["2026-09-16"]) == 1
|
|
||||||
|
|
||||||
def test_no_callback_still_appends(
|
|
||||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
|
||||||
) -> None:
|
|
||||||
"""Callers that only want the log filled (no reward) keep working."""
|
|
||||||
locker = create_locker(mock_tk, tmp_path)
|
|
||||||
log_file = tmp_path / "log.json"
|
|
||||||
log_file.write_text("{}")
|
|
||||||
_stub_phone(locker, {"2026-09-16"})
|
|
||||||
|
|
||||||
with patch("screen_locker._log_mixin.compute_entry_hmac", return_value="sig"):
|
|
||||||
assert locker._try_fill_runnerup_for_date("2026-09-16", log_file) is True
|
|
||||||
|
|
||||||
def test_week_scan_passes_callback_to_every_fill(
|
|
||||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
|
||||||
) -> None:
|
|
||||||
"""The week scan forwards ``on_ingested`` to each day it fills."""
|
|
||||||
locker = create_locker(mock_tk, tmp_path)
|
|
||||||
log_file = tmp_path / "log.json"
|
|
||||||
log_file.write_text("{}")
|
|
||||||
fill = MagicMock(return_value=True)
|
|
||||||
object.__setattr__(locker, "_has_adb_device", MagicMock(return_value=True))
|
|
||||||
object.__setattr__(locker, "_try_fill_runnerup_for_date", fill)
|
|
||||||
callback = MagicMock()
|
|
||||||
|
|
||||||
filled = locker._scan_and_fill_week_runnerup(log_file, on_ingested=callback)
|
|
||||||
|
|
||||||
assert filled == fill.call_count >= 1
|
|
||||||
assert all(call.args[2] is callback for call in fill.call_args_list)
|
|
||||||
|
|
||||||
|
|
||||||
class TestSyncPassCreditsRunnerUp:
|
|
||||||
"""``_auto_fill_week_runnerup_bonus`` (the 15-minute timer path)."""
|
|
||||||
|
|
||||||
def test_first_run_of_the_day_pushes_shutdown_two_hours(
|
|
||||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
|
||||||
) -> None:
|
|
||||||
"""Base 20:00 + today's first counted workout = 22:00 -- the day rule."""
|
|
||||||
locker = create_locker(mock_tk, tmp_path)
|
|
||||||
locker.log_file.write_text("{}")
|
|
||||||
_stub_phone(locker, {"2026-09-16"})
|
|
||||||
object.__setattr__(
|
|
||||||
locker,
|
|
||||||
"_scan_and_fill_week_runnerup",
|
|
||||||
lambda log, on_ingested=None: locker._try_fill_runnerup_for_date(
|
|
||||||
"2026-09-16", log, on_ingested
|
|
||||||
),
|
|
||||||
)
|
|
||||||
config = {"hours": (20, 20, 5)}
|
|
||||||
|
|
||||||
def write(mw: int, ts: int, me: int, restore: bool = False) -> bool:
|
|
||||||
config["hours"] = (mw, ts, me)
|
|
||||||
return True
|
|
||||||
|
|
||||||
object.__setattr__(
|
|
||||||
locker,
|
|
||||||
"_read_shutdown_config",
|
|
||||||
MagicMock(side_effect=lambda: config["hours"]),
|
|
||||||
)
|
|
||||||
object.__setattr__(
|
|
||||||
locker, "_write_shutdown_config", MagicMock(side_effect=write)
|
|
||||||
)
|
|
||||||
|
|
||||||
with (
|
|
||||||
patch("screen_locker._log_mixin.compute_entry_hmac", return_value="sig"),
|
|
||||||
patch("screen_locker._workout_credit._sick_tracker.load_history") as hist,
|
|
||||||
):
|
|
||||||
hist.return_value.debt = 0
|
|
||||||
locker._auto_fill_week_runnerup_bonus()
|
|
||||||
locker._auto_fill_week_runnerup_bonus()
|
|
||||||
|
|
||||||
assert config["hours"] == (22, 22, 5)
|
|
||||||
assert locker.workout_data == {}
|
|
||||||
@ -89,9 +89,6 @@ class TestBranchCoverageGaps:
|
|||||||
"_run_adb",
|
"_run_adb",
|
||||||
MagicMock(return_value=(True, dup_files)),
|
MagicMock(return_value=(True, dup_files)),
|
||||||
)
|
)
|
||||||
# The adb listing only runs with a device attached (the WebDAV drop
|
|
||||||
# dir is searched first and needs no phone).
|
|
||||||
object.__setattr__(locker, "_has_adb_device", MagicMock(return_value=True))
|
|
||||||
result = locker._find_runnerup_exports_for_date("2024-03-15")
|
result = locker._find_runnerup_exports_for_date("2024-03-15")
|
||||||
# Dedup: only one path in the result
|
# Dedup: only one path in the result
|
||||||
assert len(result) >= 1
|
assert len(result) >= 1
|
||||||
|
|||||||
@ -141,7 +141,6 @@ class TestFindRunnerupExportsForDate:
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""_run_adb returning False → empty list."""
|
"""_run_adb returning False → empty list."""
|
||||||
locker = create_locker(mock_tk, tmp_path)
|
locker = create_locker(mock_tk, tmp_path)
|
||||||
object.__setattr__(locker, "_has_adb_device", MagicMock(return_value=True))
|
|
||||||
object.__setattr__(locker, "_run_adb", MagicMock(return_value=(False, "")))
|
object.__setattr__(locker, "_run_adb", MagicMock(return_value=(False, "")))
|
||||||
assert locker._find_runnerup_exports_for_date("2024-03-15") == []
|
assert locker._find_runnerup_exports_for_date("2024-03-15") == []
|
||||||
|
|
||||||
@ -153,7 +152,6 @@ class TestFindRunnerupExportsForDate:
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""ADB listing with no date-matching .tcx files → empty list."""
|
"""ADB listing with no date-matching .tcx files → empty list."""
|
||||||
locker = create_locker(mock_tk, tmp_path)
|
locker = create_locker(mock_tk, tmp_path)
|
||||||
object.__setattr__(locker, "_has_adb_device", MagicMock(return_value=True))
|
|
||||||
object.__setattr__(
|
object.__setattr__(
|
||||||
locker,
|
locker,
|
||||||
"_run_adb",
|
"_run_adb",
|
||||||
@ -174,9 +172,6 @@ class TestFindRunnerupExportsForDate:
|
|||||||
"_run_adb",
|
"_run_adb",
|
||||||
MagicMock(return_value=(True, "RunnerUp_2024-03-15-10-30-00_act.tcx\n")),
|
MagicMock(return_value=(True, "RunnerUp_2024-03-15-10-30-00_act.tcx\n")),
|
||||||
)
|
)
|
||||||
# The adb listing only runs with a device attached (the WebDAV drop
|
|
||||||
# dir is searched first and needs no phone).
|
|
||||||
object.__setattr__(locker, "_has_adb_device", MagicMock(return_value=True))
|
|
||||||
result = locker._find_runnerup_exports_for_date("2024-03-15")
|
result = locker._find_runnerup_exports_for_date("2024-03-15")
|
||||||
assert len(result) >= 1
|
assert len(result) >= 1
|
||||||
assert "2024-03-15" in result[0]
|
assert "2024-03-15" in result[0]
|
||||||
|
|||||||
@ -1,198 +0,0 @@
|
|||||||
"""RunnerUp exports are read from the WebDAV drop directory, phone optional.
|
|
||||||
|
|
||||||
RunnerUp's WebDAV synchroniser uploads every export to dufs on this machine
|
|
||||||
(``RUNNERUP_WEBDAV_DIRS``), minutes after the run ends, and endurain-import
|
|
||||||
moves them to ``processed/``. Reading those files credits the run without the
|
|
||||||
phone being adb-reachable: on 2026-09-16 the TCX was on disk at 20:08 and the
|
|
||||||
phone was only plugged in at 20:25.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
from unittest.mock import MagicMock, patch
|
|
||||||
|
|
||||||
from screen_locker.tests.conftest import create_locker
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
_TCX = """\
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<TrainingCenterDatabase
|
|
||||||
xmlns="http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2">
|
|
||||||
<Activities>
|
|
||||||
<Activity Sport="Running">
|
|
||||||
<Lap>
|
|
||||||
<TotalTimeSeconds>4200.0</TotalTimeSeconds>
|
|
||||||
<DistanceMeters>5800.0</DistanceMeters>
|
|
||||||
</Lap>
|
|
||||||
</Activity>
|
|
||||||
</Activities>
|
|
||||||
</TrainingCenterDatabase>
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def _webdav_tree(tmp_path: Path) -> tuple[Path, Path]:
|
|
||||||
inbox = tmp_path / "cloud" / "RunnerUp"
|
|
||||||
processed = inbox / "processed"
|
|
||||||
processed.mkdir(parents=True)
|
|
||||||
return inbox, processed
|
|
||||||
|
|
||||||
|
|
||||||
class TestLocalExportDiscovery:
|
|
||||||
"""``_find_runnerup_exports_for_date`` / ``_has_runnerup_source``."""
|
|
||||||
|
|
||||||
def test_local_files_found_without_adb(
|
|
||||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
|
||||||
) -> None:
|
|
||||||
"""Inbox and processed/ are both searched; adb is never asked."""
|
|
||||||
locker = create_locker(mock_tk, tmp_path)
|
|
||||||
inbox, processed = _webdav_tree(tmp_path)
|
|
||||||
(inbox / "RunnerUp_Pixel_6a_2026-09-16-18-58-28_Running.tcx").write_text(_TCX)
|
|
||||||
(processed / "RunnerUp_2026-09-16-18-58-28_Running.tcx").write_text(_TCX)
|
|
||||||
(inbox / "RunnerUp_2026-09-16-18-58-28_Running.gpx").write_text("<gpx/>")
|
|
||||||
(processed / "RunnerUp_2026-09-01-18-04-41_Running.tcx").write_text(_TCX)
|
|
||||||
object.__setattr__(locker, "_has_adb_device", MagicMock(return_value=False))
|
|
||||||
object.__setattr__(locker, "_run_adb", MagicMock())
|
|
||||||
|
|
||||||
with patch(
|
|
||||||
"screen_locker._runnerup_verification.RUNNERUP_WEBDAV_DIRS",
|
|
||||||
(inbox, processed),
|
|
||||||
):
|
|
||||||
assert locker._has_runnerup_source() is True
|
|
||||||
found = locker._find_runnerup_exports_for_date("2026-09-16")
|
|
||||||
|
|
||||||
assert found == [
|
|
||||||
str(inbox / "RunnerUp_Pixel_6a_2026-09-16-18-58-28_Running.tcx"),
|
|
||||||
str(processed / "RunnerUp_2026-09-16-18-58-28_Running.tcx"),
|
|
||||||
]
|
|
||||||
locker._run_adb.assert_not_called()
|
|
||||||
|
|
||||||
def test_phone_paths_appended_after_local_when_adb_present(
|
|
||||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
|
||||||
) -> None:
|
|
||||||
"""With a phone attached the adb listing follows the local copies."""
|
|
||||||
locker = create_locker(mock_tk, tmp_path)
|
|
||||||
inbox, processed = _webdav_tree(tmp_path)
|
|
||||||
(inbox / "RunnerUp_2026-09-16-18-58-28_Running.tcx").write_text(_TCX)
|
|
||||||
object.__setattr__(locker, "_has_adb_device", MagicMock(return_value=True))
|
|
||||||
object.__setattr__(
|
|
||||||
locker,
|
|
||||||
"_run_adb",
|
|
||||||
MagicMock(
|
|
||||||
return_value=(True, "RunnerUp_2026-09-16-18-58-28_Running.tcx\n")
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
with (
|
|
||||||
patch(
|
|
||||||
"screen_locker._runnerup_verification.RUNNERUP_WEBDAV_DIRS",
|
|
||||||
(inbox, processed),
|
|
||||||
),
|
|
||||||
patch(
|
|
||||||
"screen_locker._runnerup_verification.RUNNERUP_EXPORT_DIRS",
|
|
||||||
("/sdcard/Documents/RunnerUp",),
|
|
||||||
),
|
|
||||||
):
|
|
||||||
found = locker._find_runnerup_exports_for_date("2026-09-16")
|
|
||||||
|
|
||||||
assert found == [
|
|
||||||
str(inbox / "RunnerUp_2026-09-16-18-58-28_Running.tcx"),
|
|
||||||
"/sdcard/Documents/RunnerUp/RunnerUp_2026-09-16-18-58-28_Running.tcx",
|
|
||||||
]
|
|
||||||
|
|
||||||
def test_no_source_when_dir_missing_and_no_phone(
|
|
||||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
|
||||||
) -> None:
|
|
||||||
"""Neither directory nor phone → no source, verify reports no_phone."""
|
|
||||||
locker = create_locker(mock_tk, tmp_path)
|
|
||||||
object.__setattr__(locker, "_has_adb_device", MagicMock(return_value=False))
|
|
||||||
|
|
||||||
with (
|
|
||||||
patch(
|
|
||||||
"screen_locker._runnerup_verification.RUNNERUP_WEBDAV_DIRS",
|
|
||||||
(tmp_path / "absent",),
|
|
||||||
),
|
|
||||||
patch(
|
|
||||||
"screen_locker._runnerup_verification.check_clock_skew",
|
|
||||||
return_value=(True, ""),
|
|
||||||
),
|
|
||||||
):
|
|
||||||
assert locker._has_runnerup_source() is False
|
|
||||||
status, _ = locker._verify_runnerup_workout()
|
|
||||||
assert locker._scan_and_fill_week_runnerup(tmp_path / "log.json") == 0
|
|
||||||
|
|
||||||
assert status == "no_phone"
|
|
||||||
|
|
||||||
|
|
||||||
class TestLocalVerifyAndParse:
|
|
||||||
"""The local file is parsed in place; the root-DB fallback needs adb."""
|
|
||||||
|
|
||||||
def test_verify_today_from_local_file_without_adb(
|
|
||||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
|
||||||
) -> None:
|
|
||||||
"""A today's TCX on disk verifies with the phone detached."""
|
|
||||||
locker = create_locker(mock_tk, tmp_path)
|
|
||||||
inbox, processed = _webdav_tree(tmp_path)
|
|
||||||
object.__setattr__(locker, "_has_adb_device", MagicMock(return_value=False))
|
|
||||||
object.__setattr__(locker, "_run_adb", MagicMock())
|
|
||||||
|
|
||||||
with (
|
|
||||||
patch(
|
|
||||||
"screen_locker._runnerup_verification.RUNNERUP_WEBDAV_DIRS",
|
|
||||||
(inbox, processed),
|
|
||||||
),
|
|
||||||
patch(
|
|
||||||
"screen_locker._runnerup_verification.check_clock_skew",
|
|
||||||
return_value=(True, ""),
|
|
||||||
),
|
|
||||||
patch("screen_locker._runnerup_verification.today_str") as today,
|
|
||||||
):
|
|
||||||
today.return_value = "2026-09-16"
|
|
||||||
(inbox / "RunnerUp_2026-09-16-18-58-28_Running.tcx").write_text(_TCX)
|
|
||||||
status, message = locker._verify_runnerup_workout()
|
|
||||||
|
|
||||||
assert status == "verified"
|
|
||||||
assert "5.8 km" in message
|
|
||||||
locker._run_adb.assert_not_called()
|
|
||||||
|
|
||||||
def test_no_file_and_no_adb_is_not_verified_without_db_fallback(
|
|
||||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
|
||||||
) -> None:
|
|
||||||
"""An empty drop dir with no phone cannot fall back to the root DB."""
|
|
||||||
locker = create_locker(mock_tk, tmp_path)
|
|
||||||
inbox, processed = _webdav_tree(tmp_path)
|
|
||||||
object.__setattr__(locker, "_has_adb_device", MagicMock(return_value=False))
|
|
||||||
object.__setattr__(locker, "_verify_runnerup_via_db", MagicMock())
|
|
||||||
|
|
||||||
with (
|
|
||||||
patch(
|
|
||||||
"screen_locker._runnerup_verification.RUNNERUP_WEBDAV_DIRS",
|
|
||||||
(inbox, processed),
|
|
||||||
),
|
|
||||||
patch(
|
|
||||||
"screen_locker._runnerup_verification.check_clock_skew",
|
|
||||||
return_value=(True, ""),
|
|
||||||
),
|
|
||||||
):
|
|
||||||
status, message = locker._verify_runnerup_workout()
|
|
||||||
|
|
||||||
assert status == "not_verified"
|
|
||||||
assert "not adb-reachable" in message
|
|
||||||
locker._verify_runnerup_via_db.assert_not_called()
|
|
||||||
|
|
||||||
def test_pull_and_parse_reads_local_path_in_place(
|
|
||||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
|
||||||
) -> None:
|
|
||||||
"""A path that exists locally is parsed without any adb pull."""
|
|
||||||
locker = create_locker(mock_tk, tmp_path)
|
|
||||||
tcx = tmp_path / "run.tcx"
|
|
||||||
tcx.write_text(_TCX)
|
|
||||||
object.__setattr__(locker, "_run_adb", MagicMock())
|
|
||||||
|
|
||||||
data = locker._pull_and_parse_tcx(str(tcx))
|
|
||||||
|
|
||||||
assert data is not None
|
|
||||||
assert data["distance_m"] == 5800.0
|
|
||||||
locker._run_adb.assert_not_called()
|
|
||||||
@ -14,22 +14,19 @@ if TYPE_CHECKING:
|
|||||||
class TestCheckNonVerifyExitsExtras:
|
class TestCheckNonVerifyExitsExtras:
|
||||||
"""Tests for _check_non_verify_exits coverage gaps (lines 228, 233, 251-254)."""
|
"""Tests for _check_non_verify_exits coverage gaps (lines 228, 233, 251-254)."""
|
||||||
|
|
||||||
def test_auto_fill_credits_through_shared_callback(
|
def test_logs_auto_filled_runnerup_entries(
|
||||||
self,
|
self,
|
||||||
mock_tk: MagicMock,
|
mock_tk: MagicMock,
|
||||||
mock_sys_exit: MagicMock,
|
mock_sys_exit: MagicMock,
|
||||||
tmp_path: Path,
|
tmp_path: Path,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""The login-time scan hands every fill to ``_credit_ingested_workout``.
|
"""_scan_and_fill_week_runnerup > 0 + bonus > 0 → bonus logger.info (line 188)."""
|
||||||
|
|
||||||
It used to compute a weekly-surplus bonus here (+1h per workout above
|
|
||||||
the weekly minimum), which is 0 for most of the week and silently
|
|
||||||
left a synced run uncredited (2026-09-16). No bonus is computed on
|
|
||||||
this path any more; the callback owns the reward.
|
|
||||||
"""
|
|
||||||
locker = create_locker(mock_tk, tmp_path)
|
locker = create_locker(mock_tk, tmp_path)
|
||||||
scan = MagicMock(return_value=2)
|
object.__setattr__(
|
||||||
object.__setattr__(locker, "_scan_and_fill_week_runnerup", scan)
|
locker,
|
||||||
|
"_scan_and_fill_week_runnerup",
|
||||||
|
MagicMock(return_value=2),
|
||||||
|
)
|
||||||
# Short-circuit _check_today_state_exits so the test is time-independent.
|
# Short-circuit _check_today_state_exits so the test is time-independent.
|
||||||
object.__setattr__(
|
object.__setattr__(
|
||||||
locker,
|
locker,
|
||||||
@ -43,6 +40,9 @@ class TestCheckNonVerifyExitsExtras:
|
|||||||
)
|
)
|
||||||
with (
|
with (
|
||||||
patch("screen_locker._startup_checks.reset_to_base_if_new_day"),
|
patch("screen_locker._startup_checks.reset_to_base_if_new_day"),
|
||||||
|
patch(
|
||||||
|
"screen_locker._sync_mixin.count_weekly_workouts", side_effect=[0, 6]
|
||||||
|
),
|
||||||
patch(
|
patch(
|
||||||
"screen_locker._startup_checks.process_week_transition",
|
"screen_locker._startup_checks.process_week_transition",
|
||||||
return_value=[],
|
return_value=[],
|
||||||
@ -54,10 +54,43 @@ class TestCheckNonVerifyExitsExtras:
|
|||||||
patch("screen_locker.screen_lock.sys.exit"),
|
patch("screen_locker.screen_lock.sys.exit"),
|
||||||
):
|
):
|
||||||
locker._check_non_verify_exits()
|
locker._check_non_verify_exits()
|
||||||
scan.assert_called_once_with(
|
locker._adjust_shutdown_time_by.assert_called_once_with(1) # bonus = 6-max(5,0)
|
||||||
locker.log_file, on_ingested=locker._credit_ingested_workout
|
|
||||||
|
def test_auto_fill_no_bonus_when_min_not_exceeded(
|
||||||
|
self,
|
||||||
|
mock_tk: MagicMock,
|
||||||
|
mock_sys_exit: MagicMock,
|
||||||
|
tmp_path: Path,
|
||||||
|
) -> None:
|
||||||
|
"""n_filled > 0 but new_count <= min → bonus=0 → branch 187->190 (no bonus log)."""
|
||||||
|
locker = create_locker(mock_tk, tmp_path)
|
||||||
|
object.__setattr__(
|
||||||
|
locker,
|
||||||
|
"_scan_and_fill_week_runnerup",
|
||||||
|
MagicMock(return_value=1),
|
||||||
)
|
)
|
||||||
locker._adjust_shutdown_time_by.assert_not_called()
|
object.__setattr__(
|
||||||
|
locker,
|
||||||
|
"_check_today_state_exits",
|
||||||
|
MagicMock(return_value=False),
|
||||||
|
)
|
||||||
|
with (
|
||||||
|
patch("screen_locker._startup_checks.reset_to_base_if_new_day"),
|
||||||
|
# prev=2, new=3 → bonus=max(0,3-max(5,2))=0 → no bonus logger call
|
||||||
|
patch(
|
||||||
|
"screen_locker._sync_mixin.count_weekly_workouts", side_effect=[2, 3]
|
||||||
|
),
|
||||||
|
patch(
|
||||||
|
"screen_locker._startup_checks.process_week_transition",
|
||||||
|
return_value=[],
|
||||||
|
),
|
||||||
|
patch("screen_locker._startup_checks.is_relaxed_day", return_value=False),
|
||||||
|
patch(
|
||||||
|
"screen_locker._startup_checks.has_weekly_minimum", return_value=False
|
||||||
|
),
|
||||||
|
patch("screen_locker.screen_lock.sys.exit"),
|
||||||
|
):
|
||||||
|
locker._check_non_verify_exits()
|
||||||
|
|
||||||
def test_logs_weekly_reward_message(
|
def test_logs_weekly_reward_message(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@ -56,7 +56,7 @@ class TestIngestSyncedManualWorkouts:
|
|||||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
||||||
) -> None:
|
) -> None:
|
||||||
"""The callback wired into ingest_manual_records must be
|
"""The callback wired into ingest_manual_records must be
|
||||||
``locker._credit_ingested_workout``, so a synced manual
|
``locker._credit_ingested_manual_workout``, so a synced manual
|
||||||
workout earns the same reward a live one would; workout_data is reset
|
workout earns the same reward a live one would; workout_data is reset
|
||||||
afterward so it can't leak into a later interactive flow."""
|
afterward so it can't leak into a later interactive flow."""
|
||||||
locker = create_locker(mock_tk, tmp_path)
|
locker = create_locker(mock_tk, tmp_path)
|
||||||
@ -73,14 +73,14 @@ class TestIngestSyncedManualWorkouts:
|
|||||||
):
|
):
|
||||||
locker._ingest_synced_manual_workouts()
|
locker._ingest_synced_manual_workouts()
|
||||||
assert ingest.call_args.kwargs["on_ingested"] == (
|
assert ingest.call_args.kwargs["on_ingested"] == (
|
||||||
locker._credit_ingested_workout
|
locker._credit_ingested_manual_workout
|
||||||
)
|
)
|
||||||
assert locker.workout_data == {}
|
assert locker.workout_data == {}
|
||||||
|
|
||||||
def test_credit_ingested_workout_applies_reward(
|
def test_credit_ingested_manual_workout_applies_reward(
|
||||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
||||||
) -> None:
|
) -> None:
|
||||||
"""_credit_ingested_workout sets workout_data to the ingested
|
"""_credit_ingested_manual_workout sets workout_data to the ingested
|
||||||
entry and applies the shared credit logic — proving a synced manual
|
entry and applies the shared credit logic — proving a synced manual
|
||||||
workout (today's or back-dated) earns full shutdown/debt credit,
|
workout (today's or back-dated) earns full shutdown/debt credit,
|
||||||
exactly like a live-logged one."""
|
exactly like a live-logged one."""
|
||||||
@ -92,11 +92,11 @@ class TestIngestSyncedManualWorkouts:
|
|||||||
"_apply_credit_for_written_entry",
|
"_apply_credit_for_written_entry",
|
||||||
return_value=MagicMock(shutdown_adjusted=True, extra_bonus_delta=0),
|
return_value=MagicMock(shutdown_adjusted=True, extra_bonus_delta=0),
|
||||||
) as apply_credit:
|
) as apply_credit:
|
||||||
locker._credit_ingested_workout(entry, prior)
|
locker._credit_ingested_manual_workout(entry, prior)
|
||||||
assert locker.workout_data == entry
|
assert locker.workout_data == entry
|
||||||
apply_credit.assert_called_once_with(prior)
|
apply_credit.assert_called_once_with(prior)
|
||||||
|
|
||||||
def test_credit_ingested_workout_logs_extra_bonus(
|
def test_credit_ingested_manual_workout_logs_extra_bonus(
|
||||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
||||||
) -> None:
|
) -> None:
|
||||||
"""A second same-day synced manual workout (extra_bonus_delta, not the
|
"""A second same-day synced manual workout (extra_bonus_delta, not the
|
||||||
@ -110,11 +110,11 @@ class TestIngestSyncedManualWorkouts:
|
|||||||
"_apply_credit_for_written_entry",
|
"_apply_credit_for_written_entry",
|
||||||
return_value=MagicMock(shutdown_adjusted=False, extra_bonus_delta=1),
|
return_value=MagicMock(shutdown_adjusted=False, extra_bonus_delta=1),
|
||||||
) as apply_credit:
|
) as apply_credit:
|
||||||
locker._credit_ingested_workout(entry, prior)
|
locker._credit_ingested_manual_workout(entry, prior)
|
||||||
assert locker.workout_data == entry
|
assert locker.workout_data == entry
|
||||||
apply_credit.assert_called_once_with(prior)
|
apply_credit.assert_called_once_with(prior)
|
||||||
|
|
||||||
def test_credit_ingested_workout_no_reward_logs_nothing(
|
def test_credit_ingested_manual_workout_no_reward_logs_nothing(
|
||||||
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
||||||
) -> None:
|
) -> None:
|
||||||
"""A duplicate/no-op credit result (neither shutdown_adjusted nor
|
"""A duplicate/no-op credit result (neither shutdown_adjusted nor
|
||||||
@ -128,7 +128,7 @@ class TestIngestSyncedManualWorkouts:
|
|||||||
"_apply_credit_for_written_entry",
|
"_apply_credit_for_written_entry",
|
||||||
return_value=MagicMock(shutdown_adjusted=False, extra_bonus_delta=0),
|
return_value=MagicMock(shutdown_adjusted=False, extra_bonus_delta=0),
|
||||||
) as apply_credit:
|
) as apply_credit:
|
||||||
locker._credit_ingested_workout(entry, prior)
|
locker._credit_ingested_manual_workout(entry, prior)
|
||||||
assert locker.workout_data == entry
|
assert locker.workout_data == entry
|
||||||
apply_credit.assert_called_once_with(prior)
|
apply_credit.assert_called_once_with(prior)
|
||||||
|
|
||||||
@ -191,5 +191,8 @@ class TestIngestSyncedSessions:
|
|||||||
) as ingest,
|
) as ingest,
|
||||||
):
|
):
|
||||||
locker._ingest_synced_sessions()
|
locker._ingest_synced_sessions()
|
||||||
assert ingest.call_args.kwargs["on_ingested"] == locker._credit_ingested_workout
|
assert (
|
||||||
|
ingest.call_args.kwargs["on_ingested"]
|
||||||
|
== locker._credit_ingested_manual_workout
|
||||||
|
)
|
||||||
assert locker.workout_data == {}
|
assert locker.workout_data == {}
|
||||||
|
|||||||
@ -19,54 +19,64 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
|
|
||||||
class TestRunStatusFill:
|
class TestRunStatusFill:
|
||||||
"""The RunnerUp scan block of run_status()."""
|
"""Tests for RunnerUp scan paths in run_status."""
|
||||||
|
|
||||||
def test_fill_is_credited_by_the_shared_callback(
|
def test_fill_with_bonus_applied(
|
||||||
self, tmp_path: Path, capsys: pytest.CaptureFixture
|
self, tmp_path: Path, capsys: pytest.CaptureFixture
|
||||||
) -> None:
|
) -> None:
|
||||||
"""A fill is handed to ``_credit_ingested_workout``; no bonus math here.
|
"""n_filled > 0, bonus > 0, adjust succeeds → bonus line shown.
|
||||||
|
|
||||||
The weekly-surplus rule this block used to apply (+1h per workout
|
count_weekly_workouts is called twice: before the fill (3) and after
|
||||||
above the weekly minimum) is 0 for most of the week and left a
|
(6) — a flat return_value would collapse both calls to the same
|
||||||
synced run uncredited on 2026-09-16. The reward now lives in the
|
number and mask the bonus math, so this uses side_effect instead.
|
||||||
callback; the CLI just reports the resulting shutdown hour.
|
|
||||||
"""
|
"""
|
||||||
eb_file = tmp_path / "eb.json"
|
eb_file = tmp_path / "eb.json"
|
||||||
locker = _make_locker(tmp_path / "log.json", n_filled=2, cfg=(22, 22, 5))
|
locker = _make_locker(tmp_path / "log.json", n_filled=2, bonus_applied=True)
|
||||||
with (
|
with (
|
||||||
patch("screen_locker._status.EXTRA_BENEFITS_FILE", eb_file),
|
patch("screen_locker._status.EXTRA_BENEFITS_FILE", eb_file),
|
||||||
patch("screen_locker._status.current_streak", return_value=0),
|
patch("screen_locker._status.current_streak", return_value=0),
|
||||||
patch("screen_locker._status.has_extended_early_bird", return_value=False),
|
patch("screen_locker._status.has_extended_early_bird", return_value=False),
|
||||||
patch("screen_locker._status.count_weekly_workouts", side_effect=[3, 5]),
|
patch("screen_locker._status.count_weekly_workouts", side_effect=[3, 6]),
|
||||||
patch("sys.exit"),
|
patch("sys.exit"),
|
||||||
):
|
):
|
||||||
run_status(locker)
|
run_status(locker)
|
||||||
out = capsys.readouterr().out
|
out = capsys.readouterr().out
|
||||||
assert "Auto-filled 2 workout(s)" in out
|
assert "Auto-filled 2 workout(s)" in out
|
||||||
assert "Shutdown tonight: 22:00." in out
|
assert "+1h shutdown bonus applied." in out
|
||||||
locker._scan_and_fill_week_runnerup.assert_called_once_with(
|
|
||||||
locker.log_file, on_ingested=locker._credit_ingested_workout
|
|
||||||
)
|
|
||||||
locker._adjust_shutdown_time_by.assert_not_called()
|
|
||||||
assert locker.workout_data == {}
|
|
||||||
|
|
||||||
def test_fill_with_unreadable_config_omits_hour_line(
|
def test_fill_bonus_pending_when_adjust_fails(
|
||||||
self, tmp_path: Path, capsys: pytest.CaptureFixture
|
self, tmp_path: Path, capsys: pytest.CaptureFixture
|
||||||
) -> None:
|
) -> None:
|
||||||
"""No readable config → the fill is reported without a shutdown hour."""
|
"""n_filled > 0, bonus > 0, adjust returns False → 'bonus pending' shown."""
|
||||||
eb_file = tmp_path / "eb.json"
|
eb_file = tmp_path / "eb.json"
|
||||||
locker = _make_locker(tmp_path / "log.json", n_filled=1, cfg=None)
|
locker = _make_locker(tmp_path / "log.json", n_filled=2, bonus_applied=False)
|
||||||
with (
|
with (
|
||||||
patch("screen_locker._status.EXTRA_BENEFITS_FILE", eb_file),
|
patch("screen_locker._status.EXTRA_BENEFITS_FILE", eb_file),
|
||||||
patch("screen_locker._status.current_streak", return_value=0),
|
patch("screen_locker._status.current_streak", return_value=0),
|
||||||
patch("screen_locker._status.has_extended_early_bird", return_value=False),
|
patch("screen_locker._status.has_extended_early_bird", return_value=False),
|
||||||
patch("screen_locker._status.count_weekly_workouts", side_effect=[0, 1]),
|
patch("screen_locker._status.count_weekly_workouts", side_effect=[0, 6]),
|
||||||
patch("sys.exit"),
|
patch("sys.exit"),
|
||||||
):
|
):
|
||||||
run_status(locker)
|
run_status(locker)
|
||||||
out = capsys.readouterr().out
|
out = capsys.readouterr().out
|
||||||
assert "Auto-filled 1 workout(s)" in out
|
assert "bonus pending" in out
|
||||||
assert "Shutdown tonight" not in out
|
|
||||||
|
def test_fill_no_bonus_when_still_below_min(
|
||||||
|
self, tmp_path: Path, capsys: pytest.CaptureFixture
|
||||||
|
) -> None:
|
||||||
|
"""n_filled=1 but count still < 5, before and after the fill → no bonus."""
|
||||||
|
eb_file = tmp_path / "eb.json"
|
||||||
|
locker = _make_locker(tmp_path / "log.json", n_filled=1, bonus_applied=False)
|
||||||
|
with (
|
||||||
|
patch("screen_locker._status.EXTRA_BENEFITS_FILE", eb_file),
|
||||||
|
patch("screen_locker._status.current_streak", return_value=0),
|
||||||
|
patch("screen_locker._status.has_extended_early_bird", return_value=False),
|
||||||
|
patch("screen_locker._status.count_weekly_workouts", side_effect=[2, 3]),
|
||||||
|
patch("sys.exit"),
|
||||||
|
):
|
||||||
|
run_status(locker)
|
||||||
|
out = capsys.readouterr().out
|
||||||
|
assert "shutdown bonus" not in out
|
||||||
|
|
||||||
|
|
||||||
class TestRunStatusMinimumStatus:
|
class TestRunStatusMinimumStatus:
|
||||||
|
|||||||
@ -25,32 +25,23 @@ class TestBackfillWeekAndApplyBonus:
|
|||||||
assert _backfill_week_and_apply_bonus(verifier) is None
|
assert _backfill_week_and_apply_bonus(verifier) is None
|
||||||
verifier._adjust_shutdown_time_by.assert_not_called()
|
verifier._adjust_shutdown_time_by.assert_not_called()
|
||||||
|
|
||||||
def test_runnerup_fill_is_credited_through_the_shared_callback(self) -> None:
|
def test_fill_at_or_below_minimum_earns_no_bonus(self) -> None:
|
||||||
"""A RunnerUp fill earns its day-scaled reward via ``on_ingested``.
|
"""Filling up to (not past) the weekly minimum earns no shutdown push."""
|
||||||
|
|
||||||
The weekly-surplus rule used to apply here too, which is 0 for most
|
|
||||||
of the week: on 2026-09-16 a run synced at 20:25 left the shutdown
|
|
||||||
hour at 20:00. The scan now receives the same credit callback as
|
|
||||||
every other ingestion source, and this path adds no bonus of its own.
|
|
||||||
"""
|
|
||||||
verifier = MagicMock()
|
verifier = MagicMock()
|
||||||
verifier._scan_and_fill_week_runnerup.return_value = 1
|
verifier._scan_and_fill_week_runnerup.return_value = 1
|
||||||
verifier._try_fill_stronglifts_for_week.return_value = 0
|
verifier._try_fill_stronglifts_for_week.return_value = 0
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"screen_locker._status_view_verify.count_weekly_workouts",
|
"screen_locker._status_view_verify.count_weekly_workouts",
|
||||||
return_value=3,
|
side_effect=[3, 4],
|
||||||
):
|
):
|
||||||
message = _backfill_week_and_apply_bonus(verifier)
|
message = _backfill_week_and_apply_bonus(verifier)
|
||||||
|
|
||||||
assert message == "Auto-filled 1 workout from earlier this week."
|
assert message == "Auto-filled 1 workout from earlier this week."
|
||||||
verifier._scan_and_fill_week_runnerup.assert_called_once_with(
|
|
||||||
verifier.log_file, on_ingested=verifier._credit_ingested_workout
|
|
||||||
)
|
|
||||||
verifier._adjust_shutdown_time_by.assert_not_called()
|
verifier._adjust_shutdown_time_by.assert_not_called()
|
||||||
|
|
||||||
def test_stronglifts_fill_past_minimum_applies_surplus_bonus(self) -> None:
|
def test_fill_past_minimum_applies_bonus(self) -> None:
|
||||||
"""The StrongLifts fill keeps the weekly-surplus rule, net of RunnerUp fills."""
|
"""Fill past minimum applies bonus."""
|
||||||
verifier = MagicMock()
|
verifier = MagicMock()
|
||||||
verifier._scan_and_fill_week_runnerup.return_value = 1
|
verifier._scan_and_fill_week_runnerup.return_value = 1
|
||||||
verifier._try_fill_stronglifts_for_week.return_value = 1
|
verifier._try_fill_stronglifts_for_week.return_value = 1
|
||||||
@ -61,23 +52,7 @@ class TestBackfillWeekAndApplyBonus:
|
|||||||
):
|
):
|
||||||
message = _backfill_week_and_apply_bonus(verifier)
|
message = _backfill_week_and_apply_bonus(verifier)
|
||||||
|
|
||||||
# prev 4 + 1 RunnerUp fill already credited = 5; 7 - 5 = 2 surplus.
|
|
||||||
assert message == (
|
assert message == (
|
||||||
"Auto-filled 2 workouts from earlier this week. +2h shutdown time."
|
"Auto-filled 2 workouts from earlier this week. +2h shutdown time."
|
||||||
)
|
)
|
||||||
verifier._adjust_shutdown_time_by.assert_called_once_with(2)
|
verifier._adjust_shutdown_time_by.assert_called_once_with(2)
|
||||||
|
|
||||||
def test_stronglifts_fill_below_minimum_earns_no_surplus(self) -> None:
|
|
||||||
"""A StrongLifts fill that leaves the week under the minimum adds nothing."""
|
|
||||||
verifier = MagicMock()
|
|
||||||
verifier._scan_and_fill_week_runnerup.return_value = 0
|
|
||||||
verifier._try_fill_stronglifts_for_week.return_value = 1
|
|
||||||
|
|
||||||
with patch(
|
|
||||||
"screen_locker._status_view_verify.count_weekly_workouts",
|
|
||||||
side_effect=[2, 3],
|
|
||||||
):
|
|
||||||
message = _backfill_week_and_apply_bonus(verifier)
|
|
||||||
|
|
||||||
assert message == "Auto-filled 1 workout from earlier this week."
|
|
||||||
verifier._adjust_shutdown_time_by.assert_not_called()
|
|
||||||
|
|||||||
@ -63,7 +63,7 @@ class TestVerifyPhoneThenRunnerup:
|
|||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"screen_locker._status_view_verify.count_weekly_workouts",
|
"screen_locker._status_view_verify.count_weekly_workouts",
|
||||||
return_value=2,
|
side_effect=[2, 3],
|
||||||
):
|
):
|
||||||
result = _verify_phone_then_runnerup(verifier)
|
result = _verify_phone_then_runnerup(verifier)
|
||||||
|
|
||||||
@ -71,5 +71,4 @@ class TestVerifyPhoneThenRunnerup:
|
|||||||
assert (
|
assert (
|
||||||
result.week_fill_message == "Auto-filled 1 workout from earlier this week."
|
result.week_fill_message == "Auto-filled 1 workout from earlier this week."
|
||||||
)
|
)
|
||||||
# The RunnerUp fill is credited by the shared callback, not here.
|
|
||||||
verifier._adjust_shutdown_time_by.assert_not_called()
|
verifier._adjust_shutdown_time_by.assert_not_called()
|
||||||
|
|||||||
@ -291,10 +291,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: flutter_secure_storage
|
name: flutter_secure_storage
|
||||||
sha256: d4e1fb6b2cb524868929e78dc0282fa000554b22060fb53789dc481c9fc95bb8
|
sha256: d87713a152ee2f255117bdbbf43da1dea1797e0551e499e0334f0c9dcfafddd2
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "11.2.0"
|
version: "11.1.1"
|
||||||
flutter_secure_storage_darwin:
|
flutter_secure_storage_darwin:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@ -24,7 +24,7 @@ dependencies:
|
|||||||
# The break-end alert itself, on its own high-importance channel so the OS
|
# The break-end alert itself, on its own high-importance channel so the OS
|
||||||
# rings even if the Flutter isolate is busy.
|
# rings even if the Flutter isolate is busy.
|
||||||
flutter_local_notifications: 22.3.1
|
flutter_local_notifications: 22.3.1
|
||||||
flutter_secure_storage: 11.2.0
|
flutter_secure_storage: 11.1.1
|
||||||
|
|
||||||
# One-tap sign-in for the sync account. App-side only: crdt_sync stays pure
|
# One-tap sign-in for the sync account. App-side only: crdt_sync stays pure
|
||||||
# Dart so it keeps working on Linux desktop and headless.
|
# Dart so it keeps working on Linux desktop and headless.
|
||||||
|
|||||||
74
web/package-lock.json
generated
74
web/package-lock.json
generated
@ -21,7 +21,7 @@
|
|||||||
"@types/react": "19.3.0",
|
"@types/react": "19.3.0",
|
||||||
"@types/react-dom": "19.3.0",
|
"@types/react-dom": "19.3.0",
|
||||||
"@vitejs/plugin-react": "6.1.1",
|
"@vitejs/plugin-react": "6.1.1",
|
||||||
"@vitest/coverage-v8": "5.0.1",
|
"@vitest/coverage-v8": "5.0.0",
|
||||||
"eslint": "10.10.0",
|
"eslint": "10.10.0",
|
||||||
"eslint-plugin-react-hooks": "7.1.1",
|
"eslint-plugin-react-hooks": "7.1.1",
|
||||||
"eslint-plugin-react-refresh": "0.5.7",
|
"eslint-plugin-react-refresh": "0.5.7",
|
||||||
@ -30,7 +30,7 @@
|
|||||||
"typescript": "6.0.3",
|
"typescript": "6.0.3",
|
||||||
"typescript-eslint": "8.70.0",
|
"typescript-eslint": "8.70.0",
|
||||||
"vite": "8.3.0",
|
"vite": "8.3.0",
|
||||||
"vitest": "5.0.1"
|
"vitest": "5.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@adobe/css-tools": {
|
"node_modules/@adobe/css-tools": {
|
||||||
@ -124,7 +124,6 @@
|
|||||||
"integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==",
|
"integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/code-frame": "^7.29.7",
|
"@babel/code-frame": "^7.29.7",
|
||||||
"@babel/generator": "^7.29.7",
|
"@babel/generator": "^7.29.7",
|
||||||
@ -479,7 +478,6 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20.19.0"
|
"node": ">=20.19.0"
|
||||||
},
|
},
|
||||||
@ -528,7 +526,6 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20.19.0"
|
"node": ">=20.19.0"
|
||||||
}
|
}
|
||||||
@ -1097,7 +1094,6 @@
|
|||||||
"integrity": "sha512-yzr2S9HyAIdhz2/6qHgbs665Q7PKVcDF05vsOlHPxG1mo36gKVesdYVeDLnXgfjJ03CrKRk08knc6+E/9m8v2Q==",
|
"integrity": "sha512-yzr2S9HyAIdhz2/6qHgbs665Q7PKVcDF05vsOlHPxG1mo36gKVesdYVeDLnXgfjJ03CrKRk08knc6+E/9m8v2Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/code-frame": "^7.10.4",
|
"@babel/code-frame": "^7.10.4",
|
||||||
"@babel/runtime": "^7.12.5",
|
"@babel/runtime": "^7.12.5",
|
||||||
@ -1242,7 +1238,6 @@
|
|||||||
"integrity": "sha512-CzNm2FezW4VR/LjG6yUdiEgLE/rAQ9Slj5gCu/C2VrdcW7I0ahNZ8DRbHT7zOZ6r3ONgd/bsQIeSaoDGrd1C6g==",
|
"integrity": "sha512-CzNm2FezW4VR/LjG6yUdiEgLE/rAQ9Slj5gCu/C2VrdcW7I0ahNZ8DRbHT7zOZ6r3ONgd/bsQIeSaoDGrd1C6g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici-types": "~8.9.0"
|
"undici-types": "~8.9.0"
|
||||||
}
|
}
|
||||||
@ -1253,7 +1248,6 @@
|
|||||||
"integrity": "sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg==",
|
"integrity": "sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"csstype": "^3.2.2"
|
"csstype": "^3.2.2"
|
||||||
}
|
}
|
||||||
@ -1264,7 +1258,6 @@
|
|||||||
"integrity": "sha512-ZI7bU42mZXXKHn/qNLEw2IrbiINU7X5+vfgdixBHkCNpYWXjKgfQ/P+uyGb5CjOLB9UcnTeg3rylQtV2hym44Q==",
|
"integrity": "sha512-ZI7bU42mZXXKHn/qNLEw2IrbiINU7X5+vfgdixBHkCNpYWXjKgfQ/P+uyGb5CjOLB9UcnTeg3rylQtV2hym44Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@types/react": "^19.3.0"
|
"@types/react": "^19.3.0"
|
||||||
}
|
}
|
||||||
@ -1314,7 +1307,6 @@
|
|||||||
"integrity": "sha512-zYvrmj9Yxd63UGaXw+kdt6A0F0s0qveJyuatIM77bYC2DE4pgmg7a50u8LR7PRtXd0x+h+Tl3eXabGm06SWd3Q==",
|
"integrity": "sha512-zYvrmj9Yxd63UGaXw+kdt6A0F0s0qveJyuatIM77bYC2DE4pgmg7a50u8LR7PRtXd0x+h+Tl3eXabGm06SWd3Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/scope-manager": "8.70.0",
|
"@typescript-eslint/scope-manager": "8.70.0",
|
||||||
"@typescript-eslint/types": "8.70.0",
|
"@typescript-eslint/types": "8.70.0",
|
||||||
@ -1544,12 +1536,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@vitest/coverage-v8": {
|
"node_modules/@vitest/coverage-v8": {
|
||||||
"version": "5.0.1",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-5.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-5.0.0.tgz",
|
||||||
"integrity": "sha512-FRC8ACiudC3dI6MTplzRSYWHDRnIv2IPfbzs4FdoJNsMal/35sWV8hwIfV8ZcqzSPy+uXHeMVONt9CEqtOU17w==",
|
"integrity": "sha512-toMg6PZGCIa/lQNCDoASrfb1ly4hsUKXFtFYC9kD4t78o5Y6LyNJU7AENt8eHPr3quYdxaxK7hj2mnbFfUk9NA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@bcoe/v8-coverage": "^1.0.2",
|
"@bcoe/v8-coverage": "^1.0.2",
|
||||||
"@vitest/istanbul-lib-coverage": "^1.0.0",
|
"@vitest/istanbul-lib-coverage": "^1.0.0",
|
||||||
@ -1564,8 +1555,8 @@
|
|||||||
"url": "https://opencollective.com/vitest"
|
"url": "https://opencollective.com/vitest"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@vitest/browser": "5.0.1",
|
"@vitest/browser": "5.0.0",
|
||||||
"vitest": "5.0.1"
|
"vitest": "5.0.0"
|
||||||
},
|
},
|
||||||
"peerDependenciesMeta": {
|
"peerDependenciesMeta": {
|
||||||
"@vitest/browser": {
|
"@vitest/browser": {
|
||||||
@ -1597,14 +1588,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@vitest/mocker": {
|
"node_modules/@vitest/mocker": {
|
||||||
"version": "5.0.1",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.0.0.tgz",
|
||||||
"integrity": "sha512-6K1DoBNAPGvuOcSsGA4D6x+5zEEff/KmOOP3uetT2TrGpVfI+HRHRnJJfKi5ib/g1vx8IYHQD8s0pbJz8WQI7Q==",
|
"integrity": "sha512-66PGTMIiVJP3t4a5yxU9qPtf7MdTBs8jmToMvy+HVflB3Yy13WJZTtPePdvU+wjRV02SKK5doLbSA6o9pwOmiA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jridgewell/trace-mapping": "0.3.31",
|
"@jridgewell/trace-mapping": "0.3.31",
|
||||||
"@vitest/spy": "5.0.1",
|
"@vitest/spy": "5.0.0",
|
||||||
"estree-walker": "^3.0.3",
|
"estree-walker": "^3.0.3",
|
||||||
"magic-string": "^1.2.3"
|
"magic-string": "^1.2.3"
|
||||||
},
|
},
|
||||||
@ -1625,9 +1616,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@vitest/spy": {
|
"node_modules/@vitest/spy": {
|
||||||
"version": "5.0.1",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.0.0.tgz",
|
||||||
"integrity": "sha512-rbto/mF/SGERxEgYOek7Xm6B9b+y+mVoo+f4b2LymYO8zM1b7uB5nHuhVMTP2hxdzgxvGiZYGxGIaMvL5y180Q==",
|
"integrity": "sha512-uy+luWBAPw9XfthoHi5AkfHUnuPYEESjl0p/r+meoBnU8bxg5GDQ3Ey8MjcJ6sqahkL4PFyrvfMJJBw7LbU06g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"funding": {
|
"funding": {
|
||||||
@ -1640,7 +1631,6 @@
|
|||||||
"integrity": "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==",
|
"integrity": "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"bin": {
|
"bin": {
|
||||||
"acorn": "bin/acorn"
|
"acorn": "bin/acorn"
|
||||||
},
|
},
|
||||||
@ -1803,7 +1793,6 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"baseline-browser-mapping": "^2.11.12",
|
"baseline-browser-mapping": "^2.11.12",
|
||||||
"caniuse-lite": "^1.0.30001809",
|
"caniuse-lite": "^1.0.30001809",
|
||||||
@ -2057,7 +2046,6 @@
|
|||||||
"integrity": "sha512-NPXn6r5zl4uET1DAVPaOwzX3rut4c0wcmw3dWJAfOsTM5+TogXo0DDjz8pwm/hL8cyVNpHqeK4JpN0NjnyFFNw==",
|
"integrity": "sha512-NPXn6r5zl4uET1DAVPaOwzX3rut4c0wcmw3dWJAfOsTM5+TogXo0DDjz8pwm/hL8cyVNpHqeK4JpN0NjnyFFNw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
],
|
],
|
||||||
@ -2614,7 +2602,6 @@
|
|||||||
"integrity": "sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw==",
|
"integrity": "sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@keyv/serialize": "^1.1.1"
|
"@keyv/serialize": "^1.1.1"
|
||||||
}
|
}
|
||||||
@ -2931,13 +2918,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/magic-string": {
|
"node_modules/magic-string": {
|
||||||
"version": "1.4.1",
|
"version": "1.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.2.3.tgz",
|
||||||
"integrity": "sha512-8lyCu36ErXR0J9uaGKlKQoiLZKmtI63YGLE8G2o9jyRPdr4X47LusSOwgOJOzcVtp81fTAAjxR7BwKz682Jhow==",
|
"integrity": "sha512-Bpb0W2TbLKOZ7vJnOUnVRGq3WL2p+ISV29M6hYPL1AFCpyKZpdr5ytiXoTSSxRVhg8YW7f65+6gbG8WG6PCa/g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jridgewell/sourcemap-codec": "^1.6.0"
|
"@jridgewell/sourcemap-codec": "^1.5.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/magicast": {
|
"node_modules/magicast": {
|
||||||
@ -3138,7 +3125,6 @@
|
|||||||
"integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==",
|
"integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
},
|
},
|
||||||
@ -3235,7 +3221,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/react/-/react-19.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/react/-/react-19.3.0.tgz",
|
||||||
"integrity": "sha512-E8LUcbtBWt20bbl2YoHfx4ZDBdxVTfOKtCZn9cDSJ4l6/nuoApcpIBcj47t2wZoVX8g2ZHuMHbiShgCR1T5Sog==",
|
"integrity": "sha512-E8LUcbtBWt20bbl2YoHfx4ZDBdxVTfOKtCZn9cDSJ4l6/nuoApcpIBcj47t2wZoVX8g2ZHuMHbiShgCR1T5Sog==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
@ -3245,7 +3230,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.3.0.tgz",
|
||||||
"integrity": "sha512-JDk8dgif51OjFoDE70+OT9ICyYr+69HlmihNwp1+Nsfbna3t5sIiCa9ZJktDmQ4/1b/rn26hIAR2uYXDMr5r0Q==",
|
"integrity": "sha512-JDk8dgif51OjFoDE70+OT9ICyYr+69HlmihNwp1+Nsfbna3t5sIiCa9ZJktDmQ4/1b/rn26hIAR2uYXDMr5r0Q==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"scheduler": "^0.28.0"
|
"scheduler": "^0.28.0"
|
||||||
},
|
},
|
||||||
@ -3546,7 +3530,6 @@
|
|||||||
"integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==",
|
"integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"peer": true,
|
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsc": "bin/tsc",
|
"tsc": "bin/tsc",
|
||||||
"tsserver": "bin/tsserver"
|
"tsserver": "bin/tsserver"
|
||||||
@ -3643,7 +3626,6 @@
|
|||||||
"integrity": "sha512-lhZBVvEHefgE+HQZC9O7EBJgCU/nVzFNl7vkS4RE0APtWLP02/8QVIkQtzBxPquh7lq5/78NHipTj7ODQ6XuyQ==",
|
"integrity": "sha512-lhZBVvEHefgE+HQZC9O7EBJgCU/nVzFNl7vkS4RE0APtWLP02/8QVIkQtzBxPquh7lq5/78NHipTj7ODQ6XuyQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"lightningcss": "^1.33.0",
|
"lightningcss": "^1.33.0",
|
||||||
"picomatch": "^4.0.7",
|
"picomatch": "^4.0.7",
|
||||||
@ -3717,15 +3699,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/vitest": {
|
"node_modules/vitest": {
|
||||||
"version": "5.0.1",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/vitest/-/vitest-5.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/vitest/-/vitest-5.0.0.tgz",
|
||||||
"integrity": "sha512-iA95lQbKEkvrtTkdAgnWbXfbipWiiWe/hDl2P5tMi6WFwD76G0NxXAGp/M9EOcYupeGJRr6wppMc7CoA41TQjg==",
|
"integrity": "sha512-gpsMNoRhMjMktVxPtstOH4/PJuPyovVaMDr4oDilXaGH1EcqM2OE96SoHT2VIQ6fTGtTjqmHDrEu2X9RQiXf8Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/chai": "^5.2.2",
|
"@types/chai": "^5.2.2",
|
||||||
"@vitest/mocker": "5.0.1",
|
"@vitest/mocker": "5.0.0",
|
||||||
"chai": "^6.2.2",
|
"chai": "^6.2.2",
|
||||||
"es-module-lexer": "^2.3.2",
|
"es-module-lexer": "^2.3.2",
|
||||||
"expect-type": "^1.4.0",
|
"expect-type": "^1.4.0",
|
||||||
@ -3751,12 +3732,12 @@
|
|||||||
"@edge-runtime/vm": "*",
|
"@edge-runtime/vm": "*",
|
||||||
"@opentelemetry/api": "^1.9.0",
|
"@opentelemetry/api": "^1.9.0",
|
||||||
"@types/node": "^22.0.0 || >=24.0.0",
|
"@types/node": "^22.0.0 || >=24.0.0",
|
||||||
"@vitest/browser-playwright": "5.0.1",
|
"@vitest/browser-playwright": "5.0.0",
|
||||||
"@vitest/browser-preview": "5.0.1",
|
"@vitest/browser-preview": "5.0.0",
|
||||||
"@vitest/browser-webdriverio": "^5.0.0-beta.5 || >=5.0.0",
|
"@vitest/browser-webdriverio": "^5.0.0-beta.5 || >=5.0.0",
|
||||||
"@vitest/coverage-istanbul": "5.0.1",
|
"@vitest/coverage-istanbul": "5.0.0",
|
||||||
"@vitest/coverage-v8": "5.0.1",
|
"@vitest/coverage-v8": "5.0.0",
|
||||||
"@vitest/ui": "5.0.1",
|
"@vitest/ui": "5.0.0",
|
||||||
"happy-dom": "*",
|
"happy-dom": "*",
|
||||||
"jsdom": "*",
|
"jsdom": "*",
|
||||||
"vite": "^6.4.0 || ^7.0.0 || ^8.0.0"
|
"vite": "^6.4.0 || ^7.0.0 || ^8.0.0"
|
||||||
@ -3934,7 +3915,6 @@
|
|||||||
"integrity": "sha512-sC95tT5iHHH9gtpj6A81kh+NEaRAUFN+qlUPDUbRfOMvNf5QCBqsb3WgvnpVtK5Y+4UfA6KqufotuTvMGiTlsA==",
|
"integrity": "sha512-sC95tT5iHHH9gtpj6A81kh+NEaRAUFN+qlUPDUbRfOMvNf5QCBqsb3WgvnpVtK5Y+4UfA6KqufotuTvMGiTlsA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/colinhacks"
|
"url": "https://github.com/sponsors/colinhacks"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
"@types/react": "19.3.0",
|
"@types/react": "19.3.0",
|
||||||
"@types/react-dom": "19.3.0",
|
"@types/react-dom": "19.3.0",
|
||||||
"@vitejs/plugin-react": "6.1.1",
|
"@vitejs/plugin-react": "6.1.1",
|
||||||
"@vitest/coverage-v8": "5.0.1",
|
"@vitest/coverage-v8": "5.0.0",
|
||||||
"eslint": "10.10.0",
|
"eslint": "10.10.0",
|
||||||
"eslint-plugin-react-hooks": "7.1.1",
|
"eslint-plugin-react-hooks": "7.1.1",
|
||||||
"eslint-plugin-react-refresh": "0.5.7",
|
"eslint-plugin-react-refresh": "0.5.7",
|
||||||
@ -36,6 +36,6 @@
|
|||||||
"typescript": "6.0.3",
|
"typescript": "6.0.3",
|
||||||
"typescript-eslint": "8.70.0",
|
"typescript-eslint": "8.70.0",
|
||||||
"vite": "8.3.0",
|
"vite": "8.3.0",
|
||||||
"vitest": "5.0.1"
|
"vitest": "5.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user