feat: link DLC and soundtracks to parent games
CI / test (push) Successful in 32s

Add games.parent_appid (schema v9), parse appinfo parent links, show addons and parent game in the card, and add import_steam.py --refresh-parents for existing databases.
This commit is contained in:
strsv committed 2026-11-07 01:36:26 +03:00
1 parent 376a2ee7a0
commit 528fcb7474
18 files changed
+135 -11

No files matched your search

+13 -1
View File
@@ -77,6 +77,9 @@ class ApiTests(unittest.TestCase):
VALUES (?,?,?,?,?,?)""", games)
playtime = [(1, 120, "2026-01-01"), (2, 0, None), (3, 30, None), (4, 0, None)]
con.executemany("INSERT INTO game_playtime (appid, minutes, last_played) VALUES (?,?,?)", playtime)
con.execute("INSERT INTO games (appid, name, type, parent_appid) "
"VALUES (5, 'Alpha DLC', 'dlc', 1)")
con.execute("INSERT INTO game_playtime (appid, minutes) VALUES (5, 0)")
installs = [(1, 1, 1024 * 1024 * 1024, "C:/Steam"), (2, 0, None, None)]
con.executemany(
"INSERT INTO game_install (appid, installed, size_bytes, library_path) VALUES (?,?,?,?)",
@@ -491,6 +494,15 @@ class ApiTests(unittest.TestCase):
finally:
con.close()
def test_game_addons_and_parent(self):
game = self.get("/api/game/1")
self.assertEqual(game["addons"], [
{"appid": 5, "name": "Alpha DLC", "type": "dlc"}])
self.assertIsNone(game["parent"])
dlc = self.get("/api/game/5")
self.assertEqual(dlc["parent"]["appid"], 1)
self.assertEqual(dlc["parent"]["name"], "Alpha")
def test_steam_friends(self):
self.assertEqual(self.get("/api/steam/friends", expect=400)["error"],
"Steam API key is not configured")
@@ -758,7 +770,7 @@ class ApiTests(unittest.TestCase):
con = sqlite3.connect(path)
try:
self.assertEqual(con.execute("PRAGMA integrity_check").fetchone()[0], "ok")
self.assertEqual(con.execute("SELECT COUNT(*) FROM games").fetchone()[0], 4)
self.assertEqual(con.execute("SELECT COUNT(*) FROM games").fetchone()[0], 5)
self.assertEqual(
con.execute("SELECT value FROM schema_meta WHERE key='schema_version'").fetchone()[0],
str(db.SCHEMA_VERSION))
+24 -2
View File
@@ -18,7 +18,8 @@ import steam_source
STEAMID = "76561198000000000"
def game_info(name, genres=None, tags=None, metacritic=None, review=None, release=None):
def game_info(name, genres=None, tags=None, metacritic=None, review=None, release=None,
parent=None):
return {
"name": name,
"type": "game",
@@ -27,6 +28,7 @@ def game_info(name, genres=None, tags=None, metacritic=None, review=None, releas
"metacritic": metacritic,
"review_pct": review,
"release": release,
"parent": parent,
}
@@ -38,7 +40,7 @@ class ImportSteamTests(unittest.TestCase):
self.db_path = os.path.join(self.root, "test.db")
def _run(self, appinfo, playtime=None, installed=None, lib_ids=None,
incremental=False, no_network=True):
incremental=False, no_network=True, extra_args=None):
playtime = playtime or {}
installed = installed or {}
lib_ids = lib_ids if lib_ids is not None else list(appinfo)
@@ -53,6 +55,8 @@ class ImportSteamTests(unittest.TestCase):
argv.append("--incremental")
if no_network:
argv.append("--no-network")
if extra_args:
argv.extend(extra_args)
patches = [
mock.patch.object(sys, "argv", argv),
@@ -81,6 +85,24 @@ class ImportSteamTests(unittest.TestCase):
def _personal(self, con, appid):
return con.execute("SELECT * FROM personal WHERE appid = ?", (appid,)).fetchone()
def test_import_writes_parent(self):
appinfo = {
100: game_info("Base"),
200: game_info("Addon", parent=100),
}
appinfo[200]["type"] = "dlc"
con = self._run(appinfo)
self.assertEqual(self._game(con, 200)["parent_appid"], 100)
def test_refresh_parents_updates_existing(self):
appinfo = {100: game_info("Base"), 200: game_info("Addon")}
con = self._run(appinfo)
con.close()
appinfo[200]["type"] = "dlc"
appinfo[200]["parent"] = 100
con = self._run(appinfo, extra_args=["--refresh-parents"])
self.assertEqual(self._game(con, 200)["parent_appid"], 100)
def test_full_import_writes_all_tables(self):
appinfo = {
100: game_info("Alpha", genres={"0": 25, "1": 3, "2": 30}, tags={"0": 10, "1": 20},
+2 -1
View File
@@ -207,7 +207,8 @@ class ReadAppinfoTests(unittest.TestCase):
self.assertIsInstance(result, dict)
self.assertTrue(result, "real appinfo.vdf should contain apps")
expected_keys = {"name", "type", "genres", "tags", "metacritic", "review_pct", "release"}
expected_keys = {"name", "type", "genres", "tags", "metacritic", "review_pct",
"release", "parent"}
for appid, info in result.items():
self.assertIsInstance(appid, int)
self.assertEqual(set(info), expected_keys)