refactor: move ten command helpers into packages

This commit is contained in:
Abdessamad Derraz committed 2026-11-21 15:47:20 +01:00
1 parent 6d21a98342
commit 19681a3735
22 files changed
+218 -191

No files matched your search

+4
View File
@@ -40,6 +40,8 @@ COMMANDS = {
),
"refresh_data_dirs.py": ("packs/datadirs.py",),
"split_pack.py": ("packs/parts.py",),
"retired_files.py": ("model/retired.py", "collection/retiredhistory.py"),
"region_audit.py": ("resolve/regionaudit.py",),
"dedup.py": (
"model/nodedup.py", "collection/dedup.py", "collection/duplicates.py",
"collection/clonemap.py",
@@ -78,6 +80,8 @@ COMMANDS = {
"validate_site.py": ("sitegen/validate.py",),
"site_insights.py": ("sitegen/insights.py",),
"generate_readme.py": ("sitegen/readme.py",),
"indexnow.py": ("sitegen/indexnow.py",),
"generate_report_excerpt.py": ("sitegen/reportexcerpt.py",),
"romset_recipes.py": (
"romrecipes/romsets.py", "romrecipes/pool.py", "romrecipes/pins.py",
"romrecipes/identify.py", "romrecipes/ledger.py", "romrecipes/members.py",
+1 -3
View File
@@ -289,7 +289,6 @@ class RestoreSkipsDownloadsInProgress(unittest.TestCase):
"""A scratch file another run is still writing is neither hashed nor read."""
def test_a_scratch_promoted_mid_scan_does_not_stop_the_restore(self) -> None:
import restore_large_files
from release import restore
with tempfile.TemporaryDirectory() as tmp:
@@ -307,8 +306,7 @@ class RestoreSkipsDownloadsInProgress(unittest.TestCase):
os.replace(scratch, cache / "big.bin")
return found
with mock.patch.object(restore_large_files.os.path, "isfile",
side_effect=check_then_promote):
with mock.patch.object(os.path, "isfile", side_effect=check_then_promote):
index = restore.index_cache(str(cache))
self.assertNotIn(str(scratch), index.values())
self.assertIn(str(cache / "done.bin"), index.values())
+4 -4
View File
@@ -7187,15 +7187,15 @@ class TheEventSchemaFileIsEventKeys(unittest.TestCase):
generator.build_schema()
def test_the_check_command_fails_on_a_stale_file(self):
import generate_event_schema as generator
import generate_event_schema as command
scratch = scratch_dir(self) / "events.schema.json"
scratch.write_text("{}\n", encoding="utf-8")
with contextlib.redirect_stdout(io.StringIO()), \
contextlib.redirect_stderr(io.StringIO()):
self.assertEqual(generator.main(["--check", "--output", str(scratch)]), 1)
self.assertEqual(generator.main(["--output", str(scratch)]), 0)
self.assertEqual(generator.main(["--check", "--output", str(scratch)]), 0)
self.assertEqual(command.main(["--check", "--output", str(scratch)]), 1)
self.assertEqual(command.main(["--output", str(scratch)]), 0)
self.assertEqual(command.main(["--check", "--output", str(scratch)]), 0)
class TheInstallerPageIsWrittenFromTheCode(unittest.TestCase):
+2 -3
View File
@@ -20,7 +20,6 @@ import zipfile
from pathlib import Path
from unittest import mock
import refresh_data_dirs as rdd
from packs import datadirs
from model.registry import load_data_dir_registry, load_versions
from packs.archive import Placed
@@ -313,11 +312,11 @@ class DryRunReport(unittest.TestCase):
def test_a_run_ends_on_its_counts(self):
self.assertEqual(
rdd.summarize({"a": True, "b": False, "c": False}, dry_run=True),
datadirs.summarize({"a": True, "b": False, "c": False}, dry_run=True),
"3 entries: 1 would refresh, 2 up to date",
)
self.assertEqual(
rdd.summarize({"a": True, "b": None}, dry_run=False),
datadirs.summarize({"a": True, "b": None}, dry_run=False),
"2 entries: 1 refreshed, 0 up to date, 1 failed",
)
+4 -4
View File
@@ -7,7 +7,7 @@ import tests
import unittest
import generate_report_excerpt
from sitegen import reportexcerpt
RUN = [
"RetroDECK: 9/10 OK, 1 untested [md5]",
@@ -26,12 +26,12 @@ RUN = [
class TheExcerptIsTheRun(unittest.TestCase):
def test_one_entry_of_each_shape_then_every_count(self):
self.assertEqual(generate_report_excerpt.excerpt(RUN), [
self.assertEqual(reportexcerpt.excerpt(RUN), [
RUN[0], RUN[1], RUN[3], RUN[4], RUN[7], RUN[8], RUN[9], RUN[10]])
def test_the_page_carries_the_block(self):
text = generate_report_excerpt.PAGE.read_text(encoding="utf-8")
self.assertIsNotNone(generate_report_excerpt.BLOCK.search(text))
text = reportexcerpt.PAGE.read_text(encoding="utf-8")
self.assertIsNotNone(reportexcerpt.BLOCK.search(text))
if __name__ == "__main__":
+1 -1
View File
@@ -13,8 +13,8 @@ import tempfile
import unittest
from pathlib import Path
import indexnow
from sitegen import agents as siteagents
from sitegen import indexnow
from sitegen import pagemarkdown
ROOT = Path(__file__).resolve().parent.parent