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:
1 parent
376a2ee7a0
commit
528fcb7474
18 files changed
+135
-11
No files matched your search
@@ -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},
|
||||
|
||||
Reference in new issue
Block a user