mirror of
https://github.com/kuhyx/screen-locker.git
synced 2026-11-10 20:27:13 +01:00
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
Tests / test (3.10) (push) Has been cancelled
Tests / test (3.11) (push) Has been cancelled
Tests / test (3.12) (push) Has been cancelled
Tests / lock-popup-safety (push) Has been cancelled
release-apk / release (APK) (push) Has been cancelled
workout-locker.timer (added in e5db254) re-runs the full lock-decision
chain every 30 minutes, but is_relaxed_day() is a pure date check with
no memory of an earlier same-day dismissal. Clicking "Skip — No
Penalty" only closed the window without persisting anything, so the
next tick re-derived reason=relaxed_day and rebuilt the same popup.
Now the skip button writes a relaxed_day_skip marker to the log
(excluded from weekly counting and sync, same treatment as heat_skip),
and the startup chain checks for it before re-entering the relaxed-day
branch. Also renames workout_log.json to log.json throughout the repo,
tests, docs, and Dart comments, since the fix touches that file anyway.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014qH2hJ6mvCJd3ZXpAJSaF7
74 lines
2.4 KiB
Python
74 lines
2.4 KiB
Python
"""Tests for _weekly_check.has_weekly_minimum.
|
|
|
|
Split out of test_weekly_check.py for the 250-line cap; the shared _dt /
|
|
_make_log helpers stay in that module and are imported here.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
from screen_locker._weekly_check import (
|
|
WEEKLY_WORKOUT_MINIMUM,
|
|
has_weekly_minimum,
|
|
)
|
|
from screen_locker.tests.test_weekly_check import _dt, _make_log
|
|
|
|
if TYPE_CHECKING:
|
|
from pathlib import Path
|
|
|
|
|
|
class TestHasWeeklyMinimum:
|
|
"""has_weekly_minimum counts verified workouts against the weekly bar."""
|
|
|
|
def test_zero_workouts_is_false(self, tmp_path: Path) -> None:
|
|
"""An empty log does not meet the weekly minimum."""
|
|
log = tmp_path / "log.json"
|
|
assert has_weekly_minimum(log, today=_dt(4)) is False
|
|
|
|
def test_three_workouts_is_false(self, tmp_path: Path) -> None:
|
|
"""Three workouts is short of the five-workout bar."""
|
|
log = tmp_path / "log.json"
|
|
_make_log(
|
|
{
|
|
"2025-05-19": "phone_verified",
|
|
"2025-05-20": "phone_verified",
|
|
"2025-05-21": "phone_verified",
|
|
},
|
|
log,
|
|
)
|
|
assert has_weekly_minimum(log, today=_dt(4)) is False
|
|
|
|
def test_four_workouts_is_false(self, tmp_path: Path) -> None:
|
|
"""Four workouts is still one short of the bar."""
|
|
log = tmp_path / "log.json"
|
|
_make_log(
|
|
{
|
|
"2025-05-19": "phone_verified",
|
|
"2025-05-20": "phone_verified",
|
|
"2025-05-21": "phone_verified",
|
|
"2025-05-22": "phone_verified",
|
|
},
|
|
log,
|
|
)
|
|
assert has_weekly_minimum(log, today=_dt(4)) is False
|
|
|
|
def test_five_workouts_is_true(self, tmp_path: Path) -> None:
|
|
"""Five workouts meets the bar exactly."""
|
|
log = tmp_path / "log.json"
|
|
_make_log(
|
|
{
|
|
"2025-05-19": "phone_verified",
|
|
"2025-05-20": "phone_verified",
|
|
"2025-05-21": "phone_verified",
|
|
"2025-05-22": "phone_verified",
|
|
"2025-05-23": "phone_verified",
|
|
},
|
|
log,
|
|
)
|
|
assert has_weekly_minimum(log, today=_dt(4)) is True
|
|
|
|
def test_weekly_workout_minimum_constant(self) -> None:
|
|
"""The bar is five workouts per ISO week."""
|
|
assert WEEKLY_WORKOUT_MINIMUM == 5
|