steam-backlog-enforcer/steam_installer/tests/_cli_helpers.py
Krzysztof kuhy Rudnicki a76e726e36 Merge steam-game-installer into the repo
The installer ships as the steam_installer package beside
steam_backlog_enforcer, with its tests, docs and Proton lock. The
enforcer's fast install now starts the installer from this checkout.

Both appinfo.vdf readers share one key-value decoder
(steam_installer.appinfo_kv), and the duplicated test fixtures and
helpers are folded into conftest and _cli_helpers so the whole-tree
duplicate-code check is clean. check_requirements_sync treats sibling
packages as first-party.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWZCxnNWLtpVwFLVk9w
2026-11-22 20:25:39 +01:00

44 lines
1.3 KiB
Python

"""Stubs shared by the CLI flow tests (plain functions, not fixtures)."""
from __future__ import annotations
from typing import TYPE_CHECKING
from steam_installer import appinfo, depotdl, recognize
if TYPE_CHECKING:
from pathlib import Path
import pytest
ARGV = ["--appid", "1771300", "--username", "u", "--language", "english"]
def _stub_download(monkeypatch: pytest.MonkeyPatch, returncode: int = 0) -> None:
monkeypatch.setattr(depotdl, "download", lambda appid, pull, logger: returncode)
def proven_plan(
monkeypatch: pytest.MonkeyPatch,
install_dir: Path,
shared_owner: dict[str, str] | None = None,
shared: set[str] | None = None,
) -> str:
"""Stub the depot plan so the cached manifest proves the public build.
*shared* defaults to the depots *shared_owner* names. Returns the gid.
"""
gid = next(iter(recognize.discover_cached_depot_manifests(install_dir).values()))
shared_depots = set(shared_owner or ()) if shared is None else shared
monkeypatch.setattr(
appinfo,
"get_depot_plan",
lambda appid, language: appinfo.DepotPlan(
{"1771303"},
shared_depots,
manifests={"1771303": gid},
shared_owner=dict(shared_owner or {}),
),
)
return gid