steam-backlog-enforcer/steam_backlog_enforcer/tests/test_main_gate.py
Krzysztof kuhy Rudnicki d2565416aa Pylint gate covers tests, no suppressions
Tests are now linted by the 10.00 gate (ignore-paths dropped), with no
per-test disables. CtlServer/DaemonControl members the tests drive are
public (renamed, behaviour unchanged); SteamAPIClient._get takes its
params explicitly, as every caller already did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 12:17:07 +01:00

46 lines
1.7 KiB
Python

"""Tests for main._gate: the CLI's printing, exiting half of the lock gate."""
from __future__ import annotations
from unittest.mock import patch
import pytest
from steam_backlog_enforcer.config import Config, State
from steam_backlog_enforcer.main import _gate
_PKG = "steam_backlog_enforcer.main._gate"
_CONFIGURED = Config(steam_api_key="k", steam_id="i")
class TestEnforceGate:
"""enforce_gate prints and exits for the CLI lock gate."""
def test_unconfigured_prints_and_exits(self) -> None:
"""An unconfigured CLI prints the setup hint and exits 1."""
with patch(f"{_PKG}._echo") as echo, pytest.raises(SystemExit) as exc:
_gate.enforce_gate("status", Config())
assert exc.value.code == 1
echo.assert_called_once_with(_gate.NOT_CONFIGURED_MSG)
def test_passes_through_the_loaded_state(self) -> None:
"""A configured command runs both locks and returns the loaded state."""
state = State(current_app_id=5)
with (
patch.object(State, "load", return_value=state),
patch(f"{_PKG}._enforce_total_block_lock") as total,
patch(f"{_PKG}._enforce_manual_pick_lock") as pick,
):
assert _gate.enforce_gate("scan", _CONFIGURED) is state
total.assert_called_once_with("scan")
pick.assert_called_once_with("scan", state)
def test_setup_runs_without_a_key(self) -> None:
"""setup is allowed through before a Steam key exists."""
with (
patch.object(State, "load", return_value=State()),
patch(f"{_PKG}._enforce_total_block_lock"),
patch(f"{_PKG}._enforce_manual_pick_lock"),
):
assert isinstance(_gate.enforce_gate("setup", Config()), State)