mirror of
https://github.com/kuhyx/screen-locker.git
synced 2026-07-04 11:43:09 +02:00
Extracted from testsAndMisc monorepo. Changes: - Rewrote imports from python_pkg.screen_locker.* → screen_locker.* - Vendored python_pkg.shared.log_integrity → screen_locker._log_integrity - Vendored wake_alarm constants (ALARM_DAYS, WAKE_AFTER_HOURS, RTCWAKE_BIN) into _constants.py - Extracted has_workout_skip_today into new screen_locker._wake_state module - Added tests for _wake_state.py (392 tests, 100% branch coverage) - Moved scripts/service files to repo root - Added standalone pyproject.toml, requirements.txt, .pre-commit-config.yaml, .gitignore - Added GitHub Actions CI workflows Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
84 lines
2.5 KiB
Python
84 lines
2.5 KiB
Python
"""Tests for wake alarm skip integration in screen_lock.py."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
from screen_locker.tests.conftest import create_locker
|
|
|
|
if TYPE_CHECKING:
|
|
from pathlib import Path
|
|
|
|
|
|
class TestWakeSkipIntegration:
|
|
"""Tests for workout skip via wake alarm in screen locker init."""
|
|
|
|
def test_exits_when_wake_skip_active(
|
|
self,
|
|
mock_tk: MagicMock,
|
|
mock_sys_exit: MagicMock,
|
|
tmp_path: Path,
|
|
) -> None:
|
|
"""Screen locker exits if wake alarm granted workout skip today."""
|
|
with patch(
|
|
"screen_locker.screen_lock.has_workout_skip_today",
|
|
return_value=True,
|
|
):
|
|
create_locker(mock_tk, tmp_path, has_logged=False)
|
|
|
|
mock_sys_exit.assert_called_once_with(0)
|
|
|
|
def test_does_not_exit_when_no_wake_skip(
|
|
self,
|
|
mock_tk: MagicMock,
|
|
mock_sys_exit: MagicMock,
|
|
tmp_path: Path,
|
|
) -> None:
|
|
"""Screen locker proceeds normally if no wake skip active."""
|
|
with patch(
|
|
"screen_locker.screen_lock.has_workout_skip_today",
|
|
return_value=False,
|
|
):
|
|
locker = create_locker(mock_tk, tmp_path, has_logged=False)
|
|
|
|
mock_sys_exit.assert_not_called()
|
|
assert locker is not None
|
|
|
|
def test_logged_today_takes_precedence(
|
|
self,
|
|
mock_tk: MagicMock,
|
|
mock_sys_exit: MagicMock,
|
|
tmp_path: Path,
|
|
) -> None:
|
|
"""has_logged_today exits before wake skip is even checked."""
|
|
with patch(
|
|
"screen_locker.screen_lock.has_workout_skip_today",
|
|
return_value=True,
|
|
):
|
|
create_locker(mock_tk, tmp_path, has_logged=True)
|
|
|
|
# Exits because has_logged_today, not because of wake skip
|
|
mock_sys_exit.assert_called_once_with(0)
|
|
|
|
def test_verify_only_mode_ignores_wake_skip(
|
|
self,
|
|
mock_tk: MagicMock,
|
|
mock_sys_exit: MagicMock,
|
|
tmp_path: Path,
|
|
) -> None:
|
|
"""verify_only mode checks sick day log, not wake skip."""
|
|
with patch(
|
|
"screen_locker.screen_lock.has_workout_skip_today",
|
|
return_value=True,
|
|
):
|
|
create_locker(
|
|
mock_tk,
|
|
tmp_path,
|
|
verify_only=True,
|
|
is_sick_day_log=True,
|
|
)
|
|
|
|
# In verify_only mode, exits don't happen from wake skip path
|
|
mock_sys_exit.assert_not_called()
|