mirror of
https://github.com/kuhyx/steam-backlog-enforcer.git
synced 2026-11-11 13:27:33 +01:00
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>
59 lines
1.6 KiB
Python
59 lines
1.6 KiB
Python
"""Shared fixtures for the zero-achievement "always allowed" tests."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import re
|
|
from typing import TYPE_CHECKING
|
|
|
|
from steam_backlog_enforcer import config
|
|
from steam_backlog_enforcer._achievement_skip import _cache_file
|
|
|
|
if TYPE_CHECKING:
|
|
from collections.abc import Callable
|
|
from pathlib import Path
|
|
|
|
SIMS3 = 47890
|
|
ASSIGNED = 1091500
|
|
WITH_ACH = 570
|
|
STEAM_ID = "76561198009649542"
|
|
NOW = 1_000_000_000.0
|
|
|
|
|
|
def write(path: Path, payload: object) -> None:
|
|
"""Store *payload* as JSON at *path*, as the real config writers do."""
|
|
path.write_text(json.dumps(payload), encoding="utf-8")
|
|
|
|
|
|
def confirm_zero(*app_ids: int, steam_id: str = STEAM_ID) -> None:
|
|
"""Make the real cache say Steam answered "no achievements" for these."""
|
|
write(config.CONFIG_FILE, {"steam_id": STEAM_ID})
|
|
write(
|
|
_cache_file(),
|
|
{"steam_id": steam_id, "checked": {str(a): NOW for a in app_ids}},
|
|
)
|
|
|
|
|
|
def write_snapshot(*app_ids: int) -> None:
|
|
"""Make the snapshot list these apps, each with achievements to earn."""
|
|
write(
|
|
config.SNAPSHOT_FILE, [{"app_id": a, "total_achievements": 5} for a in app_ids]
|
|
)
|
|
|
|
|
|
def recorder(removed: list[int]) -> Callable[..., bool]:
|
|
"""An ``uninstall_game`` stand-in that notes which app was removed."""
|
|
|
|
def record(app_id: int, _name: str = "") -> bool:
|
|
removed.append(app_id)
|
|
return True
|
|
|
|
return record
|
|
|
|
|
|
def js_list(pattern: str, js: str) -> list[int]:
|
|
"""Pull the JSON app-id list that *pattern* captures out of *js*."""
|
|
match = re.search(pattern, js)
|
|
assert match is not None
|
|
return list(json.loads(match.group(1)))
|