steam-backlog-enforcer/steam_installer/tests/_acf_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

80 lines
1.9 KiB
Python

"""Manifest helpers for tests that need a Steam library on disk."""
from __future__ import annotations
from typing import TYPE_CHECKING
from steam_installer import vdf
if TYPE_CHECKING:
from pathlib import Path
from steam_installer.library import SteamLibrary
GHOST_ACF = """"AppState"
{
\t"appid"\t\t"284160"
\t"universe"\t\t"1"
\t"name"\t\t"BeamNG.drive"
\t"StateFlags"\t\t"4"
\t"installdir"\t\t"BeamNG.drive"
\t"LastUpdated"\t\t"0"
\t"SizeOnDisk"\t\t"0"
\t"StagingSize"\t\t"0"
\t"buildid"\t\t"24617469"
\t"DownloadType"\t\t"1"
\t"BytesToDownload"\t\t"0"
\t"BytesDownloaded"\t\t"0"
\t"TargetBuildID"\t\t"24617469"
\t"InstalledDepots"
\t{
\t}
\t"UserConfig"
\t{
\t\t"language"\t\t"english"
\t}
}
"""
def _write(library: SteamLibrary, appid: int, text: str) -> Path:
path = library.steamapps / f"appmanifest_{appid}.acf"
path.write_text(text)
return path
def _real_install(
library: SteamLibrary,
appid: int = 475150,
installdir: str = "RealGame",
size: str = "13908166765",
) -> Path:
"""A manifest shaped like the genuinely installed apps in a live library."""
_write(
library,
appid,
vdf.dumps(
"AppState",
{
"appid": str(appid),
"StateFlags": "4",
"installdir": installdir,
"SizeOnDisk": size,
"InstalledDepots": {"475151": {"manifest": "123"}},
},
),
)
content = library.common / installdir
content.mkdir(parents=True, exist_ok=True)
(content / "game.pak").write_bytes(b"x" * 4096)
return content
def stamp_native_tool(root: Path, version: str) -> None:
"""Put a ready native Proton (manifest and version stamp) under *root*."""
tool = root / "compatibilitytools.d" / "proton-cachyos-native"
tool.mkdir(parents=True)
(tool / "toolmanifest.vdf").write_text("x")
(tool / "VERSION").write_text(version + "\n")