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>
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
"""Tests for sick-day countdown flow."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
from unittest.mock import MagicMock
|
|
|
|
from screen_locker._sick_tracker import SickHistory
|
|
from screen_locker.screen_lock import (
|
|
SICK_LOCKOUT_SECONDS,
|
|
)
|
|
from screen_locker.tests.conftest import create_locker
|
|
|
|
if TYPE_CHECKING:
|
|
from pathlib import Path
|
|
|
|
|
|
class TestProceedToSickCountdown:
|
|
"""Tests for _proceed_to_sick_countdown."""
|
|
|
|
def test_sets_up_countdown(
|
|
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
|
) -> None:
|
|
"""Countdown initialises with computed escalated value."""
|
|
locker = create_locker(mock_tk, tmp_path)
|
|
object.__setattr__(locker, "clear_container", MagicMock())
|
|
object.__setattr__(
|
|
locker, "_sick_mode_used_today", MagicMock(return_value=False)
|
|
)
|
|
object.__setattr__(
|
|
locker, "_adjust_shutdown_time_earlier", MagicMock(return_value=True)
|
|
)
|
|
locker._sick_history_cache = SickHistory()
|
|
locker._proceed_to_sick_countdown()
|
|
locker.clear_container.assert_called_once()
|
|
# First tick has decremented once -> base - 1
|
|
assert locker.sick_remaining_time == SICK_LOCKOUT_SECONDS - 1
|
|
|
|
|
|
class TestShowSickDayUi:
|
|
"""Tests for _show_sick_day_ui method."""
|
|
|
|
def test_displays_ui(
|
|
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
|
|
) -> None:
|
|
"""_show_sick_day_ui displays labels with explicit countdown."""
|
|
locker = create_locker(mock_tk, tmp_path)
|
|
locker._show_sick_day_ui("Test status", "#00aa00", 120)
|
|
mock_tk.Label.assert_called()
|
|
assert hasattr(locker, "sick_countdown_label")
|