feat: estimate game duration from genres and tags
CI / test (push) Successful in 15s

This commit is contained in:
strsv committed 2026-11-06 17:21:21 +03:00
1 parent b65c8c39fe
commit b2ab347129
18 files changed
+166 -25

No files matched your search

+11
View File
@@ -67,6 +67,7 @@ class SchemaVersionTests(unittest.TestCase):
self.assertIn("game_translations", tables)
self.assertIn("reco_feedback", tables)
self.assertIn("game_fts", tables)
self.assertIn("estimated_hours", self._columns(con, "games"))
def test_legacy_database_is_migrated_and_data_preserved(self):
con = sqlite3.connect(self.path)
@@ -87,6 +88,7 @@ class SchemaVersionTests(unittest.TestCase):
details = con.execute("SELECT short_description, source_appid FROM game_details WHERE appid=100").fetchone()
self.assertEqual(details["short_description"], "Old description")
self.assertIsNone(details["source_appid"])
self.assertIn("estimated_hours", self._columns(con, "games"))
fts_tables = {r[0] for r in con.execute(
"SELECT name FROM sqlite_master WHERE name='game_fts'")}
self.assertEqual(fts_tables, {"game_fts"})
@@ -103,6 +105,15 @@ class SchemaVersionTests(unittest.TestCase):
self.assertEqual(self._version(con), str(db.SCHEMA_VERSION))
self.assertEqual(con.execute("SELECT COUNT(*) c FROM games").fetchone()["c"], 1)
def test_duration_estimate(self):
self.assertEqual(db.estimate_hours({"RPG"}, set()), 30)
self.assertEqual(db.estimate_hours({"RPG"}, {"Short"}), 5)
self.assertEqual(db.estimate_hours({"Adventure"}, {"Open World", "Short"}), 5)
self.assertEqual(db.estimate_hours(set(), {"City Builder"}), 28)
self.assertEqual(db.estimate_hours(set(), {"MMORPG"}), 80)
self.assertEqual(db.estimate_hours(set(), set()), 12)
self.assertEqual(db.estimate_hours({"Casual"}, set()), 6)
def test_search_index_rebuild_and_single_game_refresh(self):
con = db.connect(self.path)
self.addCleanup(con.close)