screen-locker/screen_locker/tests/test_compliance_state_part4.py
Krzysztof kuhy Rudnicki 9ab7c09c79
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (push) Waiting to run
Tests / test (push) Waiting to run
Tests / lock-popup-safety (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
The early-bird window is the wake-alarm carrot, not a clock
05:00-08:30 (09:00 with the extended reward) locked nobody but did hold the
workout lock off on a clock that knew nothing about whether the user was
up, next to the morning-session rung that did. EarlyBirdMixin._is_early_bird_time
is now that rung's verdict: open before the alarm, during the session, and
until 11:00 once it completed in time -- exactly what wake-alarm signs. The
wake_alarm_skip rung banks the pending marker so the carrot's end still tries
a phone/RunnerUp workout before locking; early-bird-workout-check.timer moves
to 09:30:30 and 11:00:30, the two possible ends. The consumer's boot-retry
window starts at 05:00 with the refresher.

Also: the sick screen lists four past justifications, one line each -- six
full-length ones pushed it 7 px past 1366x768, which the screens-fit gate
only sees with a real history on disk. Takes @types/node 26.6.2, eslint 10.11.0.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XTdfXjbGYYrY7Quxcfz6mg
2026-09-20 08:39:44 +02:00

41 lines
1.3 KiB
Python

"""Tests for the pure, read-only predicates in _compliance_state.py."""
from __future__ import annotations
from typing import TYPE_CHECKING
from screen_locker import _compliance_state
from screen_locker._sick_tracker import SickHistory
if TYPE_CHECKING:
from pathlib import Path
class TestEarlyBirdWindowIsTheCarrot:
"""The window is whatever wake-alarm's signed file says -- no wall clock."""
def test_no_clock_predicate_remains(self) -> None:
assert not hasattr(_compliance_state, "_early_bird_window_open")
def test_window_open_mirrors_wake_skip(self, tmp_path: Path) -> None:
files = {
"log_file": tmp_path / "log.json",
"early_bird_pending_file": tmp_path / "eb.json",
}
open_ = _compliance_state.explain_lock_decision(
**files,
sick_history=SickHistory(),
weekly_minimum_met=False,
relaxed_day=False,
wake_skip=True,
)
shut = _compliance_state.explain_lock_decision(
**files,
sick_history=SickHistory(),
weekly_minimum_met=False,
relaxed_day=False,
wake_skip=False,
)
assert open_.stage == "wake_alarm_skip"
assert shut.stage == "would_lock"