screen-locker/screen_locker/tests/test_preview_finished.py
Krzysztof kuhy Rudnicki 5ba9e4b438 Pay flat bonuses by signed progress
earned_time 0.24 progress rows: the reset and sick floor pass
progress_map to resolve (workout left out, WorkoutCreditMixin owns
it); the live pass pays max(0, pay_now - applied) and stamps
<name>_bonus_minutes. A legacy <name>_bonus_date of today still
means the full bonus, so a mid-day deploy never pays twice. The
reset stamps minutes, never the date, so a partial stays open.
No progress row pays exactly as before; a credit pays in full.

Lands 5b6ac0b from the progress stack as this commit; its parent
4ed64b4 was already on main. Pins earned_time to the new tag
earned-time-v0.24.0 (utils c06f2da), in the manifests and the
pylint hook envs.

The preview keeps both sides: earners come from the day's registry
(main) and are priced through term_for with a progress row (stack).
_preview_sim.ROWS is the one row source for the live add and the
derivation; a new test pins a 1-of-2 review row on 2026-11-24 and
checks the preview pays term_for's share (10), not the flat 20.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 14:21:39 +01:00

34 lines
1.1 KiB
Python

"""The preview's "done" earner is a finished gate: a yes plus a 1/1 fact.
From 2026-11-24 a credited review with no verified fact pays 0, so the
preview's simulated yes carries the fact a finished gate signs; otherwise its
derived target would not match the live add, which ``term_for`` prices alike.
"""
from __future__ import annotations
from datetime import date
import earned_time
from screen_locker._shutdown_target import DayInputs, derive
from scripts._preview_sim import finished
_DAY = date(2026, 11, 24)
def test_finished_marks_only_the_done_earners() -> None:
"""Each done earner gets 1 of 1; the rest get nothing."""
assert finished({"review": True, "leetcode": False}) == {
"review": earned_time.Progress(1, 1)
}
def test_a_simulated_review_pays_twenty_only_with_the_fact() -> None:
"""With ``finished`` the sim's review adds its 20; the bare yes adds 0."""
flat = {"review": True}
none = derive(DayInputs(_DAY, {"review": False})).minutes
bare = derive(DayInputs(_DAY, flat)).minutes
fact = derive(DayInputs(_DAY, flat, progress=finished(flat))).minutes
assert (bare - none, fact - none) == (0, 20)