chore: merge scraper and tool fixes

This commit is contained in:
Abdessamad Derraz committed 2026-11-06 16:36:32 +01:00
commit 8e3ba2cfd3
28 files changed
+744 -215

No files matched your search

+37 -4
View File
@@ -318,8 +318,23 @@ class CoreResolutionTests(unittest.TestCase):
record.write_text(cf.json.dumps({"blobs": {"a": "1", "b": "1"}}))
cf.record_core_info({"a": "2", "b": "2"}, ["a"], record)
self.assertEqual(cf.load_core_info_record(record), {"a": "2", "b": "1"})
with self.assertRaises(ValueError):
cf.record_core_info({"a": "2"}, ["ghost"], record)
with self.assertRaises(cf.InputMissing) as raised:
cf.record_core_info({"a": "2", "ghosts": "1"}, ["ghost"], record)
self.assertIn("Did you mean: ghosts?", str(raised.exception))
def test_record_errors_are_one_line(self):
"""A mistyped core and an empty offline cache ended on a traceback."""
import subprocess # noqa: PLC0415
with tempfile.TemporaryDirectory() as tmp:
proc = subprocess.run(
[sys.executable, str(REPO_ROOT / "scripts" / "check_freshness.py"), "--offline",
"--cache-dir", tmp, "--record-coreinfo"],
capture_output=True, text=True, check=False, timeout=120,
)
self.assertEqual(proc.returncode, 1)
self.assertNotIn("Traceback", proc.stderr)
self.assertIn("run without --offline", proc.stderr)
def test_offline_without_a_cached_listing_is_skipped(self):
"""Offline, the row read UNKNOWN and failed the run as an upstream
@@ -462,10 +477,28 @@ class CatalogParsingTests(unittest.TestCase):
row = cf._check_redump_games(False)
self.assertEqual((row.status, row.items), (cf.STALE, ["sony-playstation"]))
self.assertEqual(cf._check_redump_games(True).status, cf.SKIPPED)
with mock.patch.object(cf, "_game_catalogs", return_value=[{"fetched": "2026-11-03"}]):
for rebuilt, status in (("2026-07-08", cf.OK), ("2026-11-04", cf.STALE)):
with mock.patch.object(cf, "_game_catalogs", return_value=[{"fetched": "2026-11-03"}]), \
mock.patch.object(cf, "_today", return_value="2026-11-06"):
for rebuilt, status in (("2026-11-02", cf.OK), ("2026-11-04", cf.STALE)):
with mock.patch.object(cf, "_no_intro_asset_date", return_value=rebuilt):
self.assertEqual(cf._check_nointro_games("", False).status, status)
def test_a_mirror_that_stopped_rebuilding_is_stale(self):
"""The mirror failed every daily rebuild from 2026-07-08, and both
No-Intro rows read OK: an import newer than a dead pack is no
sign of a fresh catalog."""
with mock.patch.object(cf, "_today", return_value="2026-11-06"), \
mock.patch.object(cf, "_no_intro_asset_date", return_value="2026-07-08"), \
mock.patch.object(cf, "_game_catalogs", return_value=[{"fetched": "2026-11-03"}]), \
mock.patch.object(cf, "_snapshot", return_value={"imported_at": "2026-08-08"}):
for row in (cf._check_nointro_games("", False), cf._check_no_intro("", False)):
self.assertEqual(row.status, cf.STALE)
self.assertIn("2026-07-08, 121 days ago", row.detail)
def test_the_freshness_check_reads_the_importer_mirror(self):
self.assertEqual(cf.NO_INTRO_MIRROR, cf.game_dat_importer.NOINTRO_MIRROR)
self.assertIn(cf.NO_INTRO_MIRROR.removeprefix("https://github.com/"),
cf.game_dat_importer.NOINTRO_RELEASE_API)
self.assertIn("no-intro games",
[f.subject for f in cf.check_catalogs("", True)])