mirror of
https://github.com/kuhyx/screen-locker.git
synced 2026-11-10 20:27:13 +01:00
Some checks are pending
pre-commit / pre-commit (push) Waiting to run
Tests / test (3.10) (push) Waiting to run
Tests / test (3.11) (push) Waiting to run
Tests / test (3.12) (push) Waiting to run
Tests / lock-popup-safety (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
A prior commit (6a7a7d8) accidentally captured only the _constants.py
half of an already-in-progress, uncommitted change removing
RUNNERUP_ACCEPTED_SPORTS -- leaving main broken (import error) since
_runnerup_verification.py and its 15 test files still referenced the
now-undefined constant. Committing the matching half: RunnerUp
entries are now judged purely by distance/duration, any sport
qualifies, matching how every other workout type is already treated.
Also: the new single-instance lock was not test-isolated, so every
ScreenLocker built across the suite contended for the same real
$XDG_RUNTIME_DIR/gatelock file -- only the first test won it, the
rest silently exited. Added to conftest.py's isolated-state table
(split into tests/_isolated_state.py to stay under the 250-line cap)
and added dedicated coverage for screen_locker/_instance.py.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018M5gKyYzxWG6QkCaj1wWfk
55 lines
2.0 KiB
Python
55 lines
2.0 KiB
Python
"""On-disk state paths every test must redirect away from the real files.
|
|
|
|
Split out of ``conftest.py`` (250-line cap) -- the *fixture* itself has to
|
|
stay in ``conftest.py`` (pytest only applies autouse fixtures declared
|
|
there), but this static table has no such constraint.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
# Each on-disk state path, and every module that bound it by value at import
|
|
# time. All of them need patching, not just the _constants source -- a missed
|
|
# binding lets a test write to the real file.
|
|
ISOLATED_STATE: tuple[tuple[str, tuple[str, ...]], ...] = (
|
|
(
|
|
"sick_history.json",
|
|
("_sick_tracker.SICK_HISTORY_FILE", "_constants.SICK_HISTORY_FILE"),
|
|
),
|
|
(
|
|
"early_bird_pending.json",
|
|
(
|
|
"_early_bird.EARLY_BIRD_PENDING_FILE",
|
|
"_constants.EARLY_BIRD_PENDING_FILE",
|
|
),
|
|
),
|
|
(
|
|
"extra_benefits_state.json",
|
|
(
|
|
"_constants.EXTRA_BENEFITS_FILE",
|
|
"_startup_checks.EXTRA_BENEFITS_FILE",
|
|
"_sync_mixin.EXTRA_BENEFITS_FILE",
|
|
"_early_bird.EXTRA_BENEFITS_FILE",
|
|
"_status.EXTRA_BENEFITS_FILE",
|
|
),
|
|
),
|
|
(
|
|
"sick_day_state.json",
|
|
(
|
|
"_constants.SICK_DAY_STATE_FILE",
|
|
"_startup_checks.SICK_DAY_STATE_FILE",
|
|
"_shutdown_sick_state.SICK_DAY_STATE_FILE",
|
|
),
|
|
),
|
|
("scheduled_skips.json", ("_log_mixin.SCHEDULED_SKIPS_FILE",)),
|
|
# The durable lock-decision trail. Written on EVERY locker run, so without
|
|
# this the suite would append test decisions to the user's real
|
|
# enforcement history in ~/.local/share/screen_locker/.
|
|
("decisions.jsonl", ("_decision_log.DECISION_LOG_FILE",)),
|
|
# Real $XDG_RUNTIME_DIR/gatelock file; unisolated, only the first test in
|
|
# the whole suite would win it, since it is shared across all of them.
|
|
(
|
|
"instance.lock",
|
|
("_constants.INSTANCE_LOCK_FILE", "screen_lock.INSTANCE_LOCK_FILE"),
|
|
),
|
|
)
|