screen-locker/screen_locker/tests/test_ui_and_timers_part2.py
Krzysztof kuhy Rudnicki d56ed74acc Reduce per-file-ignores by fixing lint violations across codebase
Fix ruff violations in ~15 source files and ~60+ test files to minimize
per-file-ignores in pyproject.toml. Remaining ignores are justified with
comments explaining why each suppression is necessary.

Source fixes: FBT003 (keyword args), S310 (URL validation), SLF001
(private access), T201 (print→logging), C901 (complexity), E501 (line
length), E402 (import order).

Test fixes: SIM117 (combined with), FBT (boolean args), PERF203 (try in
loop), S310/S607 (URLs/executables), E402/E501 (imports/lines), S108
(tmp paths), PLR0913 (too many args), ARG (unused args), ANN (type
annotations), RUF059 (unused unpacked vars), PT019 (fixture naming).

Remaining per-file-ignores (with justifications):
- Tests: ARG, D, PLC0415, PLR2004, S101, SLF001
- music_gen sources: PLC0415 (heavy ML lazy imports)
- moviepy_showcase: PLC0415 (circular dependency)
- generate_images: PLR0913 (matplotlib helpers need many params)
- praca_magisterska_video: E501, E402 (long paths, mpl.use)
2026-03-25 18:58:05 +01:00

48 lines
1.5 KiB
Python

"""Tests for handle_sick_day and sick day UI."""
from __future__ import annotations
from typing import TYPE_CHECKING
from unittest.mock import MagicMock
from python_pkg.screen_locker.screen_lock import (
SICK_LOCKOUT_SECONDS,
)
from python_pkg.screen_locker.tests.conftest import create_locker
if TYPE_CHECKING:
from pathlib import Path
class TestHandleSickDay:
"""Tests for handle_sick_day method."""
def test_sets_up_countdown(
self, mock_tk: MagicMock, mock_sys_exit: MagicMock, tmp_path: Path
) -> None:
"""Test handle_sick_day initializes sick day flow."""
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.handle_sick_day()
locker.clear_container.assert_called_once()
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:
"""Test _show_sick_day_ui displays labels."""
locker = create_locker(mock_tk, tmp_path)
locker._show_sick_day_ui("Test status", "#00aa00")
mock_tk.Label.assert_called()
assert hasattr(locker, "sick_countdown_label")