mirror of
https://github.com/kuhyx/screen-locker.git
synced 2026-11-11 13:47:39 +01:00
The workout lock, its explanation, the status view and the workday penalty's penalised day now ask _sick.stands_down_workout: a sick day that keeps the workout locker behaves as a normal day. The penalty's ring day is judged by the alarm switch. Shutdown (20:00 floor, grace floor, base, target, preview scripts) keeps is_sick: the floor belongs to the day, not to a locker. The one-tap button still keeps nothing. Test pool fixture and preview harness now redirect every sickdays resolve_paths binding, so keep edits never reach the real pool. Pins bumped to sickdays-v0.2.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PAhbNszs5JKdtnD4uBi3xp
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
"""Mark a day sick in the test's own (tmp) sickdays pool.
|
|
|
|
The autouse ``_no_sick_days_by_default`` fixture already points the pool at
|
|
``tmp_path``; this writes through ``sickdays.import_legacy``, the one writer
|
|
that accepts any date, so a test can mark a fixed past day as well as today.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import date
|
|
from typing import TYPE_CHECKING
|
|
|
|
import sickdays
|
|
|
|
if TYPE_CHECKING:
|
|
from collections.abc import Iterable
|
|
|
|
|
|
def mark_sick(day: date | str | None = None, *, keep: Iterable[str] = ()) -> date:
|
|
"""Mark ``day`` (default: today, local) sick and return it.
|
|
|
|
``keep`` names the lockers (``sickdays.LOCKER_*``) the day keeps active;
|
|
the default keeps none, i.e. every locker stands down, like the lock
|
|
screen's one-tap button.
|
|
"""
|
|
if day is None:
|
|
target = sickdays.today()
|
|
elif isinstance(day, str):
|
|
target = date.fromisoformat(day)
|
|
else:
|
|
target = day
|
|
if keep:
|
|
# ``now=target`` makes a past day "today", so a kept past day can be
|
|
# written; import_legacy cannot carry a keep set.
|
|
sickdays.add_sick_day(target, keep=keep, is_free=lambda _day: False, now=target)
|
|
else:
|
|
sickdays.import_legacy([target])
|
|
return target
|