67665974dc
M6 leftovers (the watcher defers to M9's trigger-mode work): - gameenv: check_gpu_powermizer (NVIDIA, X; degrades when the gpu target won't resolve), check_wine (wine --version), check_steam_client (dpkg package version); steam.client_version() helper. - core/launchers.py: detect Lutris (read-only SQLite pga.db) and Heroic (Epic legendary + GOG JSON) installed games; Game gained a `launcher` field. - Games page + `rigdoctor games` list non-Steam games alongside Steam, tagged by launcher; Run Diagnostic works on them (auto-launch stays Steam-only). - Tests for launchers (synthetic Lutris db + Heroic json). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
68 lines
2.9 KiB
Python
68 lines
2.9 KiB
Python
"""Tests for M6 non-Steam game detection (Lutris SQLite + Heroic JSON)."""
|
|
|
|
import json
|
|
import sqlite3
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
from unittest import mock
|
|
|
|
from rigdoctor.core import launchers
|
|
|
|
|
|
class LutrisTests(unittest.TestCase):
|
|
def test_reads_installed_games_only(self):
|
|
with tempfile.TemporaryDirectory() as d:
|
|
db = Path(d) / "pga.db"
|
|
con = sqlite3.connect(db)
|
|
con.execute("CREATE TABLE games (id INTEGER, name TEXT, slug TEXT, installed INTEGER)")
|
|
con.executemany(
|
|
"INSERT INTO games VALUES (?, ?, ?, ?)",
|
|
[(1, "Hades", "hades", 1), (2, "Hollow Knight", "hollow-knight", 1), (3, "Old Game", "old", 0)],
|
|
)
|
|
con.commit()
|
|
con.close()
|
|
with mock.patch.object(launchers, "LUTRIS_DB", db), \
|
|
mock.patch.object(launchers, "HEROIC_DIR", Path(d) / "nope"):
|
|
games = launchers.scan()
|
|
names = {g.name for g in games}
|
|
self.assertEqual(names, {"Hades", "Hollow Knight"})
|
|
self.assertTrue(all(g.launcher == "lutris" for g in games))
|
|
|
|
def test_missing_db_is_empty(self):
|
|
with tempfile.TemporaryDirectory() as d:
|
|
with mock.patch.object(launchers, "LUTRIS_DB", Path(d) / "absent.db"), \
|
|
mock.patch.object(launchers, "HEROIC_DIR", Path(d) / "nope"):
|
|
self.assertEqual(launchers.scan(), [])
|
|
|
|
|
|
class HeroicTests(unittest.TestCase):
|
|
def test_epic_and_gog(self):
|
|
with tempfile.TemporaryDirectory() as d:
|
|
base = Path(d) / "heroic"
|
|
(base / "legendaryConfig" / "legendary").mkdir(parents=True)
|
|
(base / "gog_store").mkdir(parents=True)
|
|
(base / "legendaryConfig" / "legendary" / "installed.json").write_text(
|
|
json.dumps({"abc123": {"title": "Control"}}))
|
|
(base / "gog_store" / "installed.json").write_text(
|
|
json.dumps({"installed": [{"appName": "777", "title": "The Witcher 3"}]}))
|
|
with mock.patch.object(launchers, "LUTRIS_DB", Path(d) / "nope.db"), \
|
|
mock.patch.object(launchers, "HEROIC_DIR", base):
|
|
names = {g.name for g in launchers.scan()}
|
|
self.assertEqual(names, {"Control", "The Witcher 3"})
|
|
|
|
def test_gog_title_falls_back_to_install_path(self):
|
|
with tempfile.TemporaryDirectory() as d:
|
|
base = Path(d) / "heroic"
|
|
(base / "gog_store").mkdir(parents=True)
|
|
(base / "gog_store" / "installed.json").write_text(
|
|
json.dumps({"installed": [{"appName": "9", "install_path": "/games/Stardew Valley"}]}))
|
|
with mock.patch.object(launchers, "LUTRIS_DB", Path(d) / "nope.db"), \
|
|
mock.patch.object(launchers, "HEROIC_DIR", base):
|
|
names = {g.name for g in launchers.scan()}
|
|
self.assertEqual(names, {"Stardew Valley"})
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|