mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
refactor: tests follow the sitegen package
This commit is contained in:
1 parent
cbfa26f315
commit
3af6f818d3
29 files changed
+206
-121
No files matched your search
+6
-4
@@ -50,9 +50,11 @@ def name(path: Path) -> str:
|
||||
|
||||
|
||||
def generator_sources() -> list[Path]:
|
||||
"""Every module whose strings reach a page: generate_site.py, each
|
||||
scripts/site*.py and the pack README writer. Listed by glob, so text
|
||||
moved out of generate_site.py stays under the guards that read it."""
|
||||
"""Every module whose strings reach a page: the commands that write the
|
||||
site, each module of scripts/sitegen/, the guides and system names it
|
||||
prints, and the pack README writer. Listed by glob, so text moved
|
||||
between the site modules stays under the guards that read it."""
|
||||
scripts = REPO_ROOT / "scripts"
|
||||
return sorted({*scripts.glob("site*.py"), scripts / "generate_site.py",
|
||||
scripts / "packs" / "readme.py"})
|
||||
*(scripts / "sitegen").glob("*.py"), scripts / "model" / "guides.py",
|
||||
scripts / "model" / "systemnames.py", scripts / "packs" / "readme.py"})
|
||||
@@ -29,6 +29,49 @@ COMMANDS = {
|
||||
"refresh_data_dirs.py": ("packs/datadirs.py",),
|
||||
"split_pack.py": ("packs/parts.py",),
|
||||
"dedup.py": ("model/nodedup.py",),
|
||||
"generate_site.py": (
|
||||
"sitegen/config.py",
|
||||
"sitegen/emulatorsindex.py",
|
||||
"sitegen/places.py",
|
||||
"sitegen/home.py",
|
||||
"sitegen/versions.py",
|
||||
"sitegen/guidepage.py",
|
||||
"sitegen/install.py",
|
||||
"sitegen/getpages.py",
|
||||
"sitegen/dataexports.py",
|
||||
"sitegen/lookup.py",
|
||||
"sitegen/apiitems.py",
|
||||
"sitegen/publish.py",
|
||||
"sitegen/datapage.py",
|
||||
"sitegen/descriptions.py",
|
||||
"sitegen/structured.py",
|
||||
"sitegen/cards.py",
|
||||
"sitegen/decorate.py",
|
||||
"sitegen/platformindex.py",
|
||||
"sitegen/parts.py",
|
||||
"sitegen/platformfiles.py",
|
||||
"sitegen/platformpage.py",
|
||||
"sitegen/systemsindex.py",
|
||||
"sitegen/provenance.py",
|
||||
"sitegen/fields.py",
|
||||
"sitegen/consolecards.py",
|
||||
"sitegen/startwith.py",
|
||||
"sitegen/systempages.py",
|
||||
"sitegen/emulatorcards.py",
|
||||
"sitegen/emulatorpage.py",
|
||||
"sitegen/gaps.py",
|
||||
"sitegen/crossref.py",
|
||||
"sitegen/reference.py",
|
||||
"sitegen/whichpack.py",
|
||||
"sitegen/nav.py",
|
||||
"sitegen/build.py",
|
||||
),
|
||||
"sitediagrams.py": ("sitegen/diagrams.py",),
|
||||
"sitesources.py": ("sitegen/sources.py",),
|
||||
"site_markdown.py": ("sitegen/pagemarkdown.py",),
|
||||
"validate_site.py": ("sitegen/validate.py",),
|
||||
"site_insights.py": ("sitegen/insights.py",),
|
||||
"generate_readme.py": ("sitegen/readme.py",),
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ class ReadmeRegressions(unittest.TestCase):
|
||||
with self.subTest(page=page):
|
||||
self.assertIn(version, (ROOT / page).read_text(encoding="utf-8"))
|
||||
self.assertIn(
|
||||
version, (ROOT / "scripts" / "generate_readme.py").read_text(encoding="utf-8")
|
||||
version, script_source("generate_readme.py")
|
||||
)
|
||||
|
||||
def test_an_older_interpreter_is_refused_before_the_first_step(self):
|
||||
@@ -4836,7 +4836,7 @@ class AFileToSourceIsAFileNotAName(unittest.TestCase):
|
||||
master.dat disappeared behind Fallout 1's."""
|
||||
|
||||
def test_rows_are_keyed_by_name_and_hash(self):
|
||||
source = (ROOT / "scripts" / "generate_site.py").read_text()
|
||||
source = script_source("generate_site.py")
|
||||
self.assertIn('key = (g["name"], g.get("identity") or f"emulator:{emu_name}")', source)
|
||||
from scripts.packs.crossref import _first_hash
|
||||
|
||||
@@ -5613,7 +5613,7 @@ class CollectionCardsCarryFullHashes(unittest.TestCase):
|
||||
CRC32 or SHA256."""
|
||||
|
||||
def test_every_hash_in_full(self):
|
||||
from scripts.generate_site import FileConsumers
|
||||
from scripts.packs.crossref import FileConsumers
|
||||
from scripts.sitegen.cards import _system_file_card
|
||||
|
||||
entry = {"name": "DUKE.RTS", "path": "bios/x/DUKE.RTS", "size": 10,
|
||||
@@ -5667,7 +5667,7 @@ class AVariantCardSaysWhatToSaveItAs(unittest.TestCase):
|
||||
the storage name, and nothing said RetroBat looks for advision.zip."""
|
||||
|
||||
def test_the_name_to_save_it_under(self):
|
||||
from scripts.generate_site import FileConsumers
|
||||
from scripts.packs.crossref import FileConsumers
|
||||
from scripts.sitegen.cards import _system_file_card
|
||||
|
||||
entry = {"name": "advision.zip", "size": 10, "sha1": "a" * 40,
|
||||
@@ -5772,8 +5772,10 @@ class SitemapDatesComeFromThePage(unittest.TestCase):
|
||||
def test_the_page_date_or_none_reaches_the_sitemap(self):
|
||||
import tempfile
|
||||
|
||||
from scripts.sitegen import decorate
|
||||
from scripts.sitegen import descriptions as sitegen_descriptions
|
||||
# decorate reads PAGE_DATA through its own import (sitegen.descriptions,
|
||||
# bare): the dict filled here is that one.
|
||||
from sitegen import decorate
|
||||
from sitegen import descriptions as sitegen_descriptions
|
||||
|
||||
saved = dict(sitegen_descriptions.PAGE_DATA)
|
||||
self.addCleanup(lambda: (sitegen_descriptions.PAGE_DATA.clear(),
|
||||
@@ -6861,7 +6863,7 @@ class DocsDescribeTheRegistriesTheyName(unittest.TestCase):
|
||||
sorted(item.strip() for item in listed.split(",")),
|
||||
sorted(NODEDUP_DIRS),
|
||||
)
|
||||
readme_gen = (ROOT / "scripts" / "generate_readme.py").read_text(encoding="utf-8")
|
||||
readme_gen = script_source("generate_readme.py")
|
||||
self.assertIn("NODEDUP_DIRS", readme_gen)
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ import unittest
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
import generate_readme
|
||||
from sitegen import readme
|
||||
from sitegen import reference
|
||||
|
||||
@@ -47,8 +46,8 @@ class CoverageReadsTheGivenProfiles(unittest.TestCase):
|
||||
seen.append(emulators_dir)
|
||||
return {"status_counts": {}, "total_files": 0, "undeclared_files": [], "details": []}
|
||||
|
||||
with mock.patch.object(generate_readme, "verify_platform", fake_verify), \
|
||||
mock.patch.object(generate_readme, "load_emulator_profiles", return_value={}):
|
||||
with mock.patch.object(readme, "verify_platform", fake_verify), \
|
||||
mock.patch.object(readme, "load_emulator_profiles", return_value={}):
|
||||
readme.compute_coverage(
|
||||
"retroarch", str(REPO_ROOT / "platforms"), {"files": {}}, emulators_dir="elsewhere"
|
||||
)
|
||||
|
||||
@@ -16,7 +16,7 @@ import unittest
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
import generate_readme
|
||||
from core import cli
|
||||
from sitegen import readme
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
@@ -120,11 +120,11 @@ class CoverageCache(unittest.TestCase):
|
||||
kept = sorted((self.work / "cache").glob("*.pickle"))
|
||||
|
||||
def missing(*_args, **_kwargs):
|
||||
raise generate_readme.InputMissing("no emulator profile directory at nosuch")
|
||||
raise cli.InputMissing("no emulator profile directory at nosuch")
|
||||
|
||||
with mock.patch.object(readme, "compute_coverage", missing), \
|
||||
mock.patch.object(readme, "_coverage_inputs", return_value="other"), \
|
||||
self.assertRaises(generate_readme.InputMissing):
|
||||
self.assertRaises(cli.InputMissing):
|
||||
self._run()
|
||||
self.assertEqual(sorted((self.work / "cache").glob("*.pickle")), kept)
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ file from and no list to check the diff against.
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
from tests.sources import script_source
|
||||
|
||||
import re
|
||||
import tempfile
|
||||
@@ -95,7 +96,7 @@ class CorrectedFilesPage(unittest.TestCase):
|
||||
entry named it: a maintainer had to scrape the HTML."""
|
||||
for platform in ("recalbox", "retropie"):
|
||||
self.assertIn(f'href="api/v1/exports/{platform}.json"', self.page)
|
||||
source = (ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
publish = source[source.index("def _publish_manifests("):]
|
||||
publish = publish[:publish.index("\ndef ")]
|
||||
self.assertIn('(_REPO_ROOT / "exports").glob("*.json")', publish)
|
||||
@@ -118,7 +119,7 @@ class CorrectedFilesPage(unittest.TestCase):
|
||||
self.assertIn("export_native.py --all --fetch", generate_exports_page([], {}))
|
||||
|
||||
def test_site_has_the_page_in_its_nav(self):
|
||||
source = (ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
self.assertIn('{"Updated platform files": "exports.md"}', source)
|
||||
workflow = (ROOT / ".github" / "workflows" / "deploy-site.yml").read_text(encoding="utf-8")
|
||||
self.assertIn('"exports/**"', workflow)
|
||||
|
||||
@@ -10,6 +10,7 @@ have vanished with it.
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
from tests.sources import script_source
|
||||
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
@@ -51,8 +52,8 @@ class ExtractTargets(unittest.TestCase):
|
||||
def test_no_generator_keeps_its_own_table(self):
|
||||
"""The which-pack page describes setups per OS, and these two were the
|
||||
per-platform copies of the registry."""
|
||||
readme = (REPO_ROOT / "scripts" / "generate_readme.py").read_text(encoding="utf-8")
|
||||
site = (REPO_ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8")
|
||||
readme = script_source("generate_readme.py")
|
||||
site = script_source("generate_site.py")
|
||||
self.assertNotIn('"RetroDECK": "`~/retrodeck/`"', readme)
|
||||
self.assertNotIn('" | RetroDECK | `~/retrodeck/` |"', site)
|
||||
|
||||
|
||||
+26
-9
@@ -19,7 +19,8 @@ from pathlib import Path
|
||||
|
||||
SCRIPTS = Path(__file__).resolve().parent.parent / "scripts"
|
||||
|
||||
PACKAGE_LAYERS = {"core": 0, "model": 1, "resolve": 2, "packs": 3, "scraper": 3, "exporter": 3, "profiling": 3}
|
||||
PACKAGE_LAYERS = {"core": 0, "model": 1, "resolve": 2, "packs": 3, "scraper": 3, "exporter": 3,
|
||||
"profiling": 3, "sitegen": 3}
|
||||
LIBRARY_LAYER = 3
|
||||
COMMAND_LAYER = 4
|
||||
|
||||
@@ -28,6 +29,7 @@ COMMAND_LAYER = 4
|
||||
SIBLING_IMPORTS: dict[str, frozenset[str]] = {
|
||||
"packs": frozenset(),
|
||||
"profiling": frozenset(),
|
||||
"sitegen": frozenset({"packs"}),
|
||||
}
|
||||
|
||||
# Top-level modules other modules of scripts/ import: library code that a
|
||||
@@ -35,19 +37,34 @@ SIBLING_IMPORTS: dict[str, frozenset[str]] = {
|
||||
NOT_YET_PACKAGED = frozenset({
|
||||
"archive_build", "autorun", "build_port", "campaign", "campaign_profiles", "campaign_rules",
|
||||
"check_buildbot_system", "check_release_assets", "commit_rules", "core_probe", "derivations",
|
||||
"generate_event_schema", "generate_readme", "generate_site", "measurement_records",
|
||||
"pin_installer", "pr_checks", "provenance_report", "release_record", "romfolders",
|
||||
"romset_recipes", "siteagents", "sitebootstrap", "sitecollection", "sitediagrams",
|
||||
"siteentries", "siteexports", "siteguides", "sitehandheld", "siteinputs", "sitemarkup",
|
||||
"sitemeasurements", "siterender", "sitesources", "sitestarlight", "sitesteps", "sitewanted",
|
||||
"sitewrite",
|
||||
"generate_event_schema", "measurement_records", "pin_installer", "pr_checks",
|
||||
"provenance_report", "release_record", "romfolders", "romset_recipes",
|
||||
})
|
||||
|
||||
# Imports from a package module to a top-level module, left for the wave that
|
||||
# packages the top-level side.
|
||||
PENDING_TOP_LEVEL_IMPORTS = frozenset({
|
||||
("packs.readme", "siteguides"),
|
||||
("packs.scope", "siterender"),
|
||||
("sitegen.build", "archive_build"),
|
||||
("sitegen.build", "provenance_report"),
|
||||
("sitegen.build", "release_record"),
|
||||
("sitegen.config", "release_record"),
|
||||
("sitegen.dataexports", "provenance_report"),
|
||||
("sitegen.decorate", "release_record"),
|
||||
("sitegen.descriptions", "release_record"),
|
||||
("sitegen.getpages", "release_record"),
|
||||
("sitegen.guidepage", "release_record"),
|
||||
("sitegen.handheld", "build_port"),
|
||||
("sitegen.measurements", "measurement_records"),
|
||||
("sitegen.platformindex", "release_record"),
|
||||
("sitegen.provenance", "provenance_report"),
|
||||
("sitegen.publish", "release_record"),
|
||||
("sitegen.readme", "archive_build"),
|
||||
("sitegen.readme", "pr_checks"),
|
||||
("sitegen.readme", "release_record"),
|
||||
("sitegen.validate", "release_record"),
|
||||
("sitegen.versions", "release_record"),
|
||||
("sitegen.wanted", "archive_build"),
|
||||
("sitegen.whichpack", "release_record"),
|
||||
})
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ from resolve.localfile import resolve_local_file
|
||||
from resolve.ownership import BUCKET_FOLDERS, names_manufacturer
|
||||
import generate_db
|
||||
from packs import manifest as packs_manifest, md5pack, naming as packs_naming, platformpack
|
||||
import generate_site
|
||||
from resolve import ownership
|
||||
from packs.coverage import verify_platform
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
@@ -236,8 +236,8 @@ class DiskRomGoesToThePc88File(_Collection):
|
||||
|
||||
class SiteSharesTheMakerTest(unittest.TestCase):
|
||||
def test_one_copy(self):
|
||||
self.assertIs(generate_site.names_manufacturer, names_manufacturer)
|
||||
self.assertIs(generate_site.BUCKET_FOLDERS, BUCKET_FOLDERS)
|
||||
self.assertIs(ownership.names_manufacturer, names_manufacturer)
|
||||
self.assertIs(ownership.BUCKET_FOLDERS, BUCKET_FOLDERS)
|
||||
|
||||
|
||||
class NoHashlessNameMatchCrossesMakers(unittest.TestCase):
|
||||
|
||||
@@ -14,6 +14,7 @@ platform has a permanent page at get/<platform>/ instead.
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
from tests.sources import script_source
|
||||
|
||||
import contextlib
|
||||
import io
|
||||
@@ -254,7 +255,7 @@ class TheTablesFollowTheField(unittest.TestCase):
|
||||
|
||||
class EverySurfaceSaysWhy(unittest.TestCase):
|
||||
def test_a_setup_page_says_no_zip_with_the_command_beside_it(self):
|
||||
import generate_site
|
||||
from model import guides
|
||||
from sitegen import guidepage
|
||||
|
||||
line = guidepage.no_zip_line("KNULLI")
|
||||
@@ -262,7 +263,7 @@ class EverySurfaceSaysWhy(unittest.TestCase):
|
||||
with contextlib.chdir(REPO_ROOT):
|
||||
block = guidepage._pack_buttons("knulli")
|
||||
guide = guidepage._guide_download(
|
||||
"knulli", "KNULLI", generate_site.GUIDES["knulli"], None, "## Download")
|
||||
"knulli", "KNULLI", guides.GUIDES["knulli"], None, "## Download")
|
||||
self.assertIn(line, block)
|
||||
self.assertIn(guidepage.NO_ZIP_FAQ, block)
|
||||
self.assertIn(line, "\n".join(guide))
|
||||
@@ -491,11 +492,10 @@ class EveryPlatformHasAPermanentPage(unittest.TestCase):
|
||||
self.assertIn("No ZIP for ", page)
|
||||
|
||||
def test_the_generator_writes_and_sweeps_them(self):
|
||||
import generate_site
|
||||
from sitegen import config
|
||||
|
||||
self.assertIn(release_record.GET_DIR, config.GENERATED_DIRS)
|
||||
source = Path(generate_site.__file__).read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
self.assertIn('write_if_changed(str(get_dir / f"{name}.md"), generate_get_page(name))',
|
||||
source)
|
||||
|
||||
@@ -548,7 +548,7 @@ class TheSiteCheckResolvesEveryGetPage(unittest.TestCase):
|
||||
self.assertNotIn("get/retroarch/", joined)
|
||||
|
||||
def test_the_cli_runs_the_check(self):
|
||||
source = (REPO_ROOT / "scripts" / "validate_site.py").read_text(encoding="utf-8")
|
||||
source = script_source("validate_site.py")
|
||||
self.assertIn("validate_site(Path(args.site_dir), args.base, args.platforms_dir, args.record)",
|
||||
source)
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ node and skip without it.
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
from tests.sources import script_source
|
||||
|
||||
import json
|
||||
import re
|
||||
@@ -734,7 +735,7 @@ class EverySonyConsoleHasItsPage(unittest.TestCase):
|
||||
found the PlayStation page before the Sony page holding the PS3."""
|
||||
|
||||
def test_sony_is_split_by_console(self):
|
||||
source = (REPO_ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
self.assertIn('CONSOLE_PAGES = frozenset({"Sony"})', source)
|
||||
self.assertIn("manufacturer in CONSOLE_PAGES", source)
|
||||
|
||||
@@ -1228,7 +1229,7 @@ class AChecksumLineIsAHash(unittest.TestCase):
|
||||
])
|
||||
|
||||
def test_the_form_takes_the_line(self):
|
||||
source = _read(REPO_ROOT / "scripts" / "generate_site.py")
|
||||
source = script_source("generate_site.py")
|
||||
start = source.index('<input id="rb-hash"')
|
||||
self.assertNotIn("pattern=", source[start:source.index("required>", start)])
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ terminal recording under the others.
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
from tests.sources import script_source
|
||||
|
||||
import json
|
||||
import re
|
||||
@@ -192,12 +193,11 @@ def _tab_bodies(markdown: str) -> dict[str, str]:
|
||||
|
||||
class TheTwoPagesShowIt(unittest.TestCase):
|
||||
def test_home_shows_the_terminal_recording(self):
|
||||
import generate_site
|
||||
from sitegen import home
|
||||
|
||||
tag = home.install_demo()[0]
|
||||
self.assertIn(f'description="{sitegen_readme.demo_description()}"', tag)
|
||||
source = Path(generate_site.__file__).read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
body = source[source.index("def generate_home("):]
|
||||
body = body[:body.index("\ndef ", 1)]
|
||||
self.assertIn("*install_demo(),", body)
|
||||
|
||||
@@ -37,7 +37,7 @@ import tempfile
|
||||
import importlib.util
|
||||
import json
|
||||
|
||||
import generate_site as gs
|
||||
from model import guides
|
||||
from sitegen import cards
|
||||
from sitegen import emulatorcards
|
||||
from sitegen import emulatorpage
|
||||
@@ -733,7 +733,7 @@ class InstallBlockWhereItWorks(unittest.TestCase):
|
||||
def test_no_os_tab_outside_the_data_root(self) -> None:
|
||||
if not _generated():
|
||||
self.skipTest("site pages not generated")
|
||||
labels = {key: gs.TERMINALS[key][0] for key in gs.TERMINALS}
|
||||
labels = {key: guides.TERMINALS[key][0] for key in guides.TERMINALS}
|
||||
for name, profile in _profiles_with_data_root().items():
|
||||
allowed = {labels["device"]}
|
||||
for key in profile["data_root"]:
|
||||
|
||||
@@ -33,6 +33,7 @@ Linux handheld rows sent the reader to a menu.
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
from tests.sources import script_source
|
||||
|
||||
import json
|
||||
import re
|
||||
@@ -43,7 +44,6 @@ from pathlib import Path
|
||||
import yaml
|
||||
|
||||
from sitegen import readme as sitegen_readme
|
||||
import generate_site
|
||||
from sitegen import config
|
||||
from sitegen import descriptions
|
||||
from sitegen import guidepage
|
||||
@@ -812,7 +812,7 @@ class EntryCopy(unittest.TestCase):
|
||||
self.assertIn("- Have a file? [Check it](/retrobios/files/)", _plain_page("index.md"))
|
||||
|
||||
def test_the_explore_cards_have_bare_links(self):
|
||||
source = Path(generate_site.__file__).read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
self.assertNotIn('"Reference: [How each platform checks files]', source)
|
||||
self.assertNotIn('"Reference: [Data and API]', source)
|
||||
|
||||
@@ -911,7 +911,7 @@ class GetPagesGiveTheSetupsOwnRoutes(unittest.TestCase):
|
||||
self.assertEqual(_tab_labels(install), {"Steam Deck", "Linux"})
|
||||
|
||||
def test_one_helper_writes_both_pages(self):
|
||||
source = Path(generate_site.__file__).read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
get_page = source.split("def generate_get_page", 1)[1].split("\ndef ", 1)[0]
|
||||
guide = source.split("def _platform_guide", 1)[1].split("\ndef ", 1)[0]
|
||||
self.assertNotIn("install_commands(", get_page)
|
||||
@@ -1111,7 +1111,7 @@ class TheSiteSaysWhatTheInstallerShows(unittest.TestCase):
|
||||
readme = (REPO_ROOT / "README.md").read_text(encoding="utf-8")
|
||||
self.assertIn(f"fewer under **{installer.TUI_SYSTEMS_ROW}**", readme)
|
||||
self.assertNotIn("offers to install everything or to choose systems", readme)
|
||||
source = (REPO_ROOT / "scripts" / "generate_readme.py").read_text(encoding="utf-8")
|
||||
source = script_source("generate_readme.py")
|
||||
self.assertIn("_installer_words().TUI_SYSTEMS_ROW", source)
|
||||
import generate_installer_doc
|
||||
|
||||
|
||||
+11
-11
@@ -3,6 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
from tests.sources import script_source
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
@@ -15,9 +16,9 @@ from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
from generate_site import _admonition_body, _source_ref_markdown
|
||||
from sitegen.sources import _forge_sources
|
||||
from sitegen.render import _admonition_body
|
||||
from sitegen.descriptions import _browser_title
|
||||
from sitegen.sources import _forge_sources, _source_ref_markdown
|
||||
from sitegen.decorate import decorate_markdown_pages
|
||||
from sitegen.dataexports import generate_data_exports
|
||||
|
||||
@@ -289,7 +290,7 @@ class PerModeSourcePins(unittest.TestCase):
|
||||
)
|
||||
|
||||
def test_sqlite_export_accepts_a_per_mode_commit(self):
|
||||
from generate_site import _json_text
|
||||
from core.artifacts import json_text as _json_text
|
||||
|
||||
self.assertEqual(
|
||||
_json_text(self.PROFILE["source_commit"]),
|
||||
@@ -652,7 +653,7 @@ class APerCoreDocumentValidates(unittest.TestCase):
|
||||
import yaml
|
||||
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
source = (root / "scripts" / "generate_site.py").read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
self.assertNotIn('json.dumps({"id": name, **profile}', source)
|
||||
envelope = json.loads((root / "schemas" / "site-api-envelope.schema.json").read_text())
|
||||
schema = json.loads((root / "schemas" / "emulator.schema.json").read_text())
|
||||
@@ -708,7 +709,7 @@ class AHashFindsEveryPageThatNamesIt(unittest.TestCase):
|
||||
import tempfile
|
||||
import zlib
|
||||
|
||||
from sitegen import lookup
|
||||
from sitegen import lookup, structured
|
||||
|
||||
body = b"approved inis\n"
|
||||
sha1 = hashlib.sha1(body).hexdigest()
|
||||
@@ -726,7 +727,8 @@ class AHashFindsEveryPageThatNamesIt(unittest.TestCase):
|
||||
"sha1": sha1, "md5": hashlib.md5(body).hexdigest(),
|
||||
"sha256": hashlib.sha256(body).hexdigest(),
|
||||
"crc32": f"{zlib.crc32(body):08x}"}})
|
||||
with mock.patch.object(lookup, "_data_member_digests", return_value=digests):
|
||||
with mock.patch.object(lookup, "_data_member_digests", return_value=digests), \
|
||||
mock.patch.object(structured, "_data_member_digests", return_value=digests):
|
||||
records = lookup.file_lookup_records(
|
||||
{"files": {}}, {}, {}, [{"sha1": sha1, "url": "u"}],
|
||||
{"dolphin-sys": {"ApprovedInis.json": {"sha1": sha1}}})
|
||||
@@ -818,9 +820,8 @@ class AnArchiveMemberIsFoundByItsCrc(unittest.TestCase):
|
||||
def test_the_lookup_and_the_schema_carry_the_layer(self):
|
||||
import json as _json
|
||||
|
||||
import generate_site
|
||||
|
||||
source = Path(generate_site.__file__).read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
self.assertIn("records += _archive_member_records(entry, sha1, item[\"url\"])", source)
|
||||
schema = _json.loads((Path(__file__).resolve().parents[1] / "schemas"
|
||||
/ "site-api-envelope.schema.json").read_text())
|
||||
@@ -854,13 +855,12 @@ class AWantedDumpIsFoundByItsHash(unittest.TestCase):
|
||||
def test_the_schema_and_the_page_carry_the_layer(self):
|
||||
import json as _json
|
||||
|
||||
import generate_site
|
||||
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
schema = _json.loads((root / "schemas" / "site-api-envelope.schema.json").read_text())
|
||||
self.assertIn('"wanted"', _json.dumps(schema))
|
||||
self.assertIn("byLayer('wanted')", (root / "website" / "src" / "scripts" / "site.ts").read_text())
|
||||
source = Path(generate_site.__file__).read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
self.assertIn('model_retired.load(_REPO_ROOT / "retired.json"), wanted)', source)
|
||||
|
||||
|
||||
@@ -1216,7 +1216,7 @@ class TheGapPageOpensOnCounts(unittest.TestCase):
|
||||
self.assertIn("1 is held but not verified", text)
|
||||
self.assertIn("0 are missing", text)
|
||||
self.assertNotIn("%", text)
|
||||
source = (Path(__file__).resolve().parents[1] / "scripts" / "generate_site.py").read_text()
|
||||
source = script_source("generate_site.py")
|
||||
self.assertNotIn("Unified view of BIOS verification", source)
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ starts it.
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
from tests.sources import script_source
|
||||
|
||||
import contextlib
|
||||
import hashlib
|
||||
@@ -103,11 +104,11 @@ class WhereEachSystemFindsItsFile(unittest.TestCase):
|
||||
def test_the_group_page_sits_with_the_handheld_guide(self):
|
||||
"""It shares the guide's name, so the sidebar files it with it, and
|
||||
the guide a muOS or ArkOS owner lands on links it."""
|
||||
import generate_site
|
||||
from model import guides
|
||||
from sitegen import getpages
|
||||
from sitegen import guidepage
|
||||
|
||||
guide = generate_site.HANDHELD_GUIDE
|
||||
guide = guides.HANDHELD_GUIDE
|
||||
self.assertEqual(sitehandheld.GROUP_PAGE, guide.page)
|
||||
with contextlib.chdir(REPO_ROOT):
|
||||
self.assertIn(f"(../get/{sitehandheld.GROUP_PAGE}.md)",
|
||||
@@ -158,7 +159,7 @@ class WhereEachSystemFindsItsFile(unittest.TestCase):
|
||||
self.assertIn(f"](../{sitehandheld.SERVED_DIR}/{name})", block.group(1))
|
||||
|
||||
def test_the_generator_writes_them(self):
|
||||
source = (REPO_ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
self.assertIn("sitehandheld.write_launchers(public, _REPO_ROOT)", source)
|
||||
self.assertIn("sitehandheld.platform_block(platform_name, _REPO_ROOT)", source)
|
||||
self.assertIn("sitehandheld.group_page(_REPO_ROOT)", source)
|
||||
|
||||
+14
-10
@@ -10,6 +10,7 @@ directory, so a get/ page said "No ZIP" for a setup the API marked as released.
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
from tests.sources import SCRIPTS, script_paths
|
||||
|
||||
import ast
|
||||
import json
|
||||
@@ -19,7 +20,7 @@ import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import generate_site
|
||||
from model import collection
|
||||
from sitegen import decorate
|
||||
from sitegen import guidepage
|
||||
from sitegen import install
|
||||
@@ -68,7 +69,7 @@ class TheGivenProfilesAndPlatforms(_Inputs):
|
||||
|
||||
def test_emulator_names_come_from_the_given_profiles(self) -> None:
|
||||
self.use(emulators=self.emulators)
|
||||
self.assertEqual(set(generate_site._profiles_on_disk()), {"fixturecore"})
|
||||
self.assertEqual(set(collection._profiles_on_disk()), {"fixturecore"})
|
||||
self.assertEqual(platformfiles._emulator_named_link("fixturecore"),
|
||||
"[Fixture Core](emulators/fixturecore.md)")
|
||||
|
||||
@@ -120,7 +121,7 @@ class TheCollectionDoesNotDependOnTheWorkingDirectory(unittest.TestCase):
|
||||
self.assertEqual(siteinputs.bios_dir({"bios_dir": "/abs/bios"}), Path("/abs/bios"))
|
||||
|
||||
def test_the_image_tools_do_not_load_the_page_generator(self) -> None:
|
||||
for module in ("make_og_cards.py", "fetch_site_images.py", "siterender.py"):
|
||||
for module in ("make_og_cards.py", "fetch_site_images.py", "sitegen/render.py"):
|
||||
with self.subTest(module=module):
|
||||
source = (REPO_ROOT / "scripts" / module).read_text(encoding="utf-8")
|
||||
self.assertNotIn("from generate_site import", source)
|
||||
@@ -130,33 +131,36 @@ class NoPageModuleReadsTheRepositoryInputs(unittest.TestCase):
|
||||
"""A helper that opens the repository's database, profiles or platform
|
||||
files itself bypasses the flags. siteinputs.current() is the one source."""
|
||||
|
||||
MODULES = ("generate_site.py", "siterender.py", "sitediagrams.py", "sitecollection.py")
|
||||
MODULES = (*script_paths("generate_site.py"), SCRIPTS / "sitegen" / "render.py",
|
||||
SCRIPTS / "sitegen" / "diagrams.py", SCRIPTS / "model" / "collection.py",
|
||||
SCRIPTS / "model" / "systemnames.py")
|
||||
INPUTS = {"database.json", "emulators", "platforms"}
|
||||
|
||||
def test_no_literal_input_path(self) -> None:
|
||||
found = []
|
||||
for module in self.MODULES:
|
||||
tree = ast.parse((REPO_ROOT / "scripts" / module).read_text(encoding="utf-8"))
|
||||
tree = ast.parse(module.read_text(encoding="utf-8"))
|
||||
for node in ast.walk(tree):
|
||||
if isinstance(node, ast.BinOp) and isinstance(node.op, ast.Div) \
|
||||
and getattr(node.left, "id", "") in ("_REPO_ROOT", "ROOT") \
|
||||
and getattr(node.left, "id", "") in ("_REPO_ROOT", "ROOT", "REPO_ROOT") \
|
||||
and isinstance(node.right, ast.Constant) and node.right.value in self.INPUTS:
|
||||
found.append(f"{module}:{node.lineno}")
|
||||
found.append(f"{module.name}:{node.lineno}")
|
||||
if isinstance(node, ast.Call) and getattr(node.func, "id", getattr(node.func, "attr", "")) in (
|
||||
"load_platform_config", "load_platform_registry", "load_emulator_profiles",
|
||||
"list_registered_platforms", "load_database", "extract_notes",
|
||||
"load_data_dir_registry"):
|
||||
found.extend(
|
||||
f"{module}:{node.lineno}"
|
||||
f"{module.name}:{node.lineno}"
|
||||
for arg in node.args
|
||||
if isinstance(arg, ast.Constant) and arg.value in self.INPUTS
|
||||
)
|
||||
self.assertEqual(found, [])
|
||||
|
||||
def test_generate_installs_the_inputs_first(self) -> None:
|
||||
build = (SCRIPTS / "sitegen" / "build.py").read_text(encoding="utf-8")
|
||||
source = ast.get_source_segment(
|
||||
(REPO_ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8"),
|
||||
next(n for n in ast.parse((REPO_ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8")).body
|
||||
build,
|
||||
next(n for n in ast.parse(build).body
|
||||
if isinstance(n, ast.FunctionDef) and n.name == "_generate"))
|
||||
self.assertLess(source.index("siteinputs.use("), source.index("load_database("))
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ are built, the pages and the site.
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
from tests.sources import script_source
|
||||
|
||||
import json
|
||||
import re
|
||||
@@ -33,7 +34,6 @@ from pathlib import Path
|
||||
import ast
|
||||
from html import unescape
|
||||
|
||||
import generate_site
|
||||
from sitegen import decorate
|
||||
from sitegen import emulatorsindex
|
||||
from sitegen import nav as sitegen_nav
|
||||
@@ -296,7 +296,7 @@ class Redirects(unittest.TestCase):
|
||||
self.assertEqual(sitestarlight.redirects({}, present), {})
|
||||
|
||||
def test_the_generator_writes_the_file(self):
|
||||
source = Path(generate_site.__file__).read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
self.assertIn('generated / "redirects.json"', source)
|
||||
|
||||
def test_a_list_part_gone_with_its_rows_redirects_to_its_page(self):
|
||||
@@ -545,7 +545,7 @@ class SystemPartsSitUnderTheirMaker(unittest.TestCase):
|
||||
|
||||
class MovedPlatformPages(unittest.TestCase):
|
||||
def test_a_setups_list_for_one_console_is_a_reference(self) -> None:
|
||||
source = Path(generate_site.__file__).read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
block = source[source.index("for stem, page in moved.items():"):]
|
||||
block = block[: block.index("PAGE_DATA[f\"platforms/{name}.md\"]")]
|
||||
self.assertIn('SEARCH_DEMOTED.add(f"platforms/{stem}.md")', block)
|
||||
|
||||
@@ -18,10 +18,10 @@ import unittest
|
||||
from html.parser import HTMLParser
|
||||
from pathlib import Path
|
||||
|
||||
import generate_site
|
||||
from sitegen import cards
|
||||
from sitegen import platformfiles
|
||||
from sitegen import platformpage
|
||||
from sitegen import sources
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
@@ -173,7 +173,7 @@ class ReferencesNameTheirRoleOnce(unittest.TestCase):
|
||||
self.assertIn(f"**{word}**", platformfiles.ROLE_LEGEND)
|
||||
|
||||
def test_other_pages_keep_the_role_after_each_reference(self):
|
||||
text = generate_site._source_ref_markdown(self.PROFILE, self.REFS)
|
||||
text = sources._source_ref_markdown(self.PROFILE, self.REFS)
|
||||
self.assertEqual(text.count("(emulator code, libretro port)"), 2)
|
||||
self.assertIn("`src/c.c:4` (upstream emulator)", text)
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ it has not been generated.
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
from tests.sources import script_source
|
||||
|
||||
import csv
|
||||
import io
|
||||
@@ -51,8 +52,8 @@ import zipfile
|
||||
import runpy
|
||||
import urllib.error
|
||||
|
||||
import generate_site
|
||||
from sitegen import apiitems
|
||||
from sitegen import cards
|
||||
from sitegen import config as sitegen_config
|
||||
from sitegen import crossref
|
||||
from sitegen import dataexports
|
||||
@@ -65,6 +66,7 @@ from sitegen import platformindex
|
||||
from sitegen import platformpage
|
||||
from sitegen import provenance
|
||||
from sitegen import publish
|
||||
from sitegen import render
|
||||
from sitegen import wanted as sitewanted
|
||||
from model import systemnames
|
||||
from model.registry import list_registered_platforms, list_release_pack_platforms
|
||||
@@ -74,7 +76,7 @@ from resolve.reconcile import HASH_FIELDS, _hash_values
|
||||
from resolve.categories import EntryCategories
|
||||
from sitegen.sources import launcher_ref_markdown, list_source
|
||||
import check_platform_folder
|
||||
import sitesources
|
||||
import core
|
||||
from sitegen import sources
|
||||
import release_record
|
||||
from core import upstream
|
||||
@@ -322,7 +324,7 @@ class GapsPageNumbers(unittest.TestCase):
|
||||
self.assertEqual(gaps._missing_required_firmware(cov), 1)
|
||||
|
||||
def test_headings_and_header(self):
|
||||
source = Path(generate_site.__file__).read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
body = source[source.index("def generate_gap_analysis("):]
|
||||
body = body[:body.index("\ndef ", 10)]
|
||||
self.assertIn('"# What the packs do not hold"', body)
|
||||
@@ -500,7 +502,7 @@ class TheExportsKeepWhatACheckNeeds(unittest.TestCase):
|
||||
self.assertEqual(flagged["zipped_file"], "")
|
||||
|
||||
def test_the_csv_header_and_the_table_name_them(self):
|
||||
source = Path(generate_site.__file__).read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
self.assertIn('"collection_path", "resolved_sha1", *ENTRY_EXPORT_FIELDS,', source)
|
||||
for field in dataexports.ENTRY_EXPORT_FIELDS:
|
||||
self.assertIn(f":{field}", source)
|
||||
@@ -688,7 +690,7 @@ class EveryEnvelopeCarriesTheCommit(unittest.TestCase):
|
||||
"""8.5: emulators/ and systems/ lacked `commit` (716 documents)."""
|
||||
|
||||
def test_the_writers_pass_it(self):
|
||||
source = Path(generate_site.__file__).read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
self.assertIn('str(db.get("generated_at") or _timestamp()), _source_commit(),\n )\n'
|
||||
" clash", source)
|
||||
block = source[source.index("public_profiles = {"):source.index("pages = emulator_pages(")]
|
||||
@@ -727,7 +729,7 @@ class ManifestsArePublished(unittest.TestCase):
|
||||
schema = json.loads((REPO_ROOT / "schemas" / "install-manifest.schema.json").read_text())
|
||||
for field in ("dest", "repo_path", "release_asset", "cores"):
|
||||
description = schema["$defs"]["file"]["properties"][field]["description"]
|
||||
self.assertIn(f"| `{field}` | {generate_site._escape_tags(description)} |", page)
|
||||
self.assertIn(f"| `{field}` | {render._escape_tags(description)} |", page)
|
||||
self.assertIn("## Platform manifests", page)
|
||||
self.assertIn("**Licence:**", page)
|
||||
self.assertIn("## Hosting, rate limits and caching", page)
|
||||
@@ -837,7 +839,7 @@ class PlatformPagesLinkTheirSystemsAndEmulators(unittest.TestCase):
|
||||
self.assertNotEqual(link, "[beetle_psx](../emulators/beetle_psx.md)")
|
||||
|
||||
def test_the_overview_column_uses_it(self):
|
||||
source = Path(generate_site.__file__).read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
block = source[source.index("### Systems overview"):source.index("_render_platform_systems(by_system")]
|
||||
self.assertIn("_emulator_named_link(e, \"../\")", block)
|
||||
self.assertNotIn('", ".join(sys_emus[:3])', block)
|
||||
@@ -859,7 +861,7 @@ class PlatformPagesLinkTheirSystemsAndEmulators(unittest.TestCase):
|
||||
sitegen_parts._list_pages("gaps-x", "T", "intro", [], [["| a |"]], moved,
|
||||
parent=("What the packs do not hold", "/gaps/"))
|
||||
self.assertIn('parent:\n label: "What the packs do not hold"\n link: "/gaps/"', moved["gaps-x"])
|
||||
source = Path(generate_site.__file__).read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
self.assertIn('_parent_front_matter(("Cores by platform", "/cross-reference/"))', source)
|
||||
self.assertIn('parent=("Dump provenance", "/provenance/")', source)
|
||||
|
||||
@@ -882,7 +884,7 @@ class TablesFitTheirColumn(unittest.TestCase):
|
||||
row = next(line for line in table.splitlines() if "x.bin" in line)
|
||||
self.assertIn(f'<code title="{"b" * 32}">{"b" * 12}</code>', row)
|
||||
self.assertIn('<span class="rb-reason">expected md5 differs</span>', row)
|
||||
source = Path(generate_site.__file__).read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
self.assertIn('expected = f"{algorithm} {short_hash(value)}"', source)
|
||||
self.assertIn("{_reason_cell(u['reason'])}", source)
|
||||
|
||||
@@ -980,7 +982,8 @@ class LookupRecordsUnderEveryHash(unittest.TestCase):
|
||||
"files": [{"name": "bios.bin", "crc32": "c" * 8}]}}
|
||||
with mock.patch.object(lookup, "_console_system_names", return_value={}), \
|
||||
mock.patch.object(lookup, "_lookup_system_name", return_value=None), \
|
||||
mock.patch.object(generate_site, "emulator_card_page", side_effect=lambda k, a: k):
|
||||
mock.patch.object(lookup, "emulator_card_page", side_effect=lambda k, a: k), \
|
||||
mock.patch.object(cards, "emulator_card_page", side_effect=lambda k, a: k):
|
||||
return lookup.file_lookup_records(
|
||||
db, coverages, profiles, [{"sha1": self.SHA1, "url": "/x"}])
|
||||
|
||||
@@ -1152,7 +1155,7 @@ class SourceLinksOnlyWhereTheFileIs(unittest.TestCase):
|
||||
profile = {"source": "https://github.com/o/r", "source_commit": "e" * 40,
|
||||
"files": [{"source_ref": "src/a.c:5"}]}
|
||||
with mock.patch.object(sources, "_cached_tree", return_value=None), \
|
||||
mock.patch.object(sitesources.upstream, "list_directory",
|
||||
mock.patch.object(core.upstream, "list_directory",
|
||||
side_effect=upstream.UpstreamError("HTTP 404")):
|
||||
held, unread = sources.build_source_paths({"p": profile}, [TMP])
|
||||
self.assertEqual(held, {})
|
||||
@@ -1391,7 +1394,8 @@ class LookupCountsEmulatorsLikeTheCard(unittest.TestCase):
|
||||
{"name": "bios.bin", "md5": "b" * 32}]}}}}}
|
||||
with mock.patch.object(lookup, "_console_system_names", return_value={}), \
|
||||
mock.patch.object(lookup, "_lookup_system_name", return_value=None), \
|
||||
mock.patch.object(generate_site, "emulator_card_page", side_effect=lambda k, a: k):
|
||||
mock.patch.object(lookup, "emulator_card_page", side_effect=lambda k, a: k), \
|
||||
mock.patch.object(cards, "emulator_card_page", side_effect=lambda k, a: k):
|
||||
return lookup.file_lookup_records(
|
||||
db, coverages, {}, [{"sha1": self.SHA1, "url": "/x"}], None,
|
||||
FakeConsumers(self.SHA1))
|
||||
|
||||
@@ -42,7 +42,7 @@ class IconsComeFromTheLocalCopies(unittest.TestCase):
|
||||
self.assertIn("A%20-%20One.png", siterender.system_icon_markdown("A", "One"))
|
||||
|
||||
def test_no_request_is_made(self):
|
||||
self.assertNotIn("urllib.request", (REPO_ROOT / "scripts" / "siterender.py").read_text())
|
||||
self.assertNotIn("urllib.request", (REPO_ROOT / "scripts" / "sitegen" / "render.py").read_text())
|
||||
|
||||
|
||||
class EveryPageAddressesPlatformsAsPeers(unittest.TestCase):
|
||||
|
||||
@@ -20,6 +20,7 @@ built, the site.
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
from tests.sources import script_source
|
||||
|
||||
import ast
|
||||
import re
|
||||
@@ -37,7 +38,6 @@ from sitegen import getpages
|
||||
from sitegen import structured
|
||||
from sitegen import starlight as sitestarlight
|
||||
from sitegen import validate
|
||||
from sitegen import structured
|
||||
from model.registry import list_registered_platforms
|
||||
from model.profiles import load_emulator_profiles
|
||||
from tests.test_site_nav import ANCHORS, _nav, _present
|
||||
@@ -154,7 +154,7 @@ class FieldsFromFrontMatter(unittest.TestCase):
|
||||
self.assertNotRegex(text, r">[^<]*bios missing[^<]*<")
|
||||
|
||||
def test_no_search_word_is_typed_in_the_module(self) -> None:
|
||||
source = (REPO_ROOT / "scripts" / "sitestarlight.py").read_text(encoding="utf-8")
|
||||
source = (REPO_ROOT / "scripts" / "sitegen" / "starlight.py").read_text(encoding="utf-8")
|
||||
for words in ("bios not found", "mame version", "WonderSwan"):
|
||||
self.assertNotIn(words, source)
|
||||
|
||||
@@ -177,7 +177,7 @@ class FindOrCheckAFile(unittest.TestCase):
|
||||
self.assertIn('data-pagefind-meta="terms:check dump md5 check"', text)
|
||||
|
||||
def test_the_sidebar_names_it_as_its_title(self) -> None:
|
||||
source = (REPO_ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
self.assertIn('{"Find or check a file": "files/index.md"}', source)
|
||||
self.assertNotIn('{"Find a file": "files/index.md"}', source)
|
||||
|
||||
@@ -327,7 +327,7 @@ class Descriptions(unittest.TestCase):
|
||||
self.assertTrue(text.startswith("Common questions: Are BIOS files needed?"))
|
||||
|
||||
def test_a_written_description_wins(self) -> None:
|
||||
source = (REPO_ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
self.assertIn('authored.get("description") or _page_description(', source)
|
||||
|
||||
def test_the_check_counts_templates(self) -> None:
|
||||
@@ -409,7 +409,7 @@ class ConsoleWordsReachTheConsole(unittest.TestCase):
|
||||
self.assertIn('data-pagefind-meta="terms:SNES BIOS"', text)
|
||||
|
||||
def test_no_search_word_is_typed_in_the_generator(self):
|
||||
tree = ast.parse((REPO_ROOT / "scripts" / "sitestarlight.py").read_text(encoding="utf-8"))
|
||||
tree = ast.parse((REPO_ROOT / "scripts" / "sitegen" / "starlight.py").read_text(encoding="utf-8"))
|
||||
docstrings = {id(node.value) for node in ast.walk(tree) if isinstance(node, ast.Expr)}
|
||||
strings = {node.value.casefold() for node in ast.walk(tree)
|
||||
if isinstance(node, ast.Constant) and isinstance(node.value, str)
|
||||
|
||||
@@ -17,7 +17,7 @@ import os
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import generate_site as gs
|
||||
from model import collection
|
||||
from sitegen import places
|
||||
from sitegen import platformfiles
|
||||
from sitegen import startwith
|
||||
@@ -54,7 +54,7 @@ class LinksFollowContent(unittest.TestCase):
|
||||
db = load_database("database.json")
|
||||
config = load_platform_config("misterfpga")
|
||||
names: dict = {}
|
||||
for mfr, consoles in gs._group_by_manufacturer(db).items():
|
||||
for mfr, consoles in collection._group_by_manufacturer(db).items():
|
||||
for console, entries in consoles.items():
|
||||
for entry in entries:
|
||||
names.setdefault(entry["name"], set()).add((mfr, console))
|
||||
@@ -136,7 +136,7 @@ class ACopyIsOnItsOwnFoldersPage(unittest.TestCase):
|
||||
"Fairchild/Channel F/sl31253.bin": ["s"], "Channel F/sl31253.bin": ["s"],
|
||||
}},
|
||||
}
|
||||
groups = gs._group_by_manufacturer(db)
|
||||
groups = collection._group_by_manufacturer(db)
|
||||
self.assertEqual(sorted(groups), ["Arcade", "Fairchild"])
|
||||
self.assertEqual(list(groups["Fairchild"]), ["Channel F"])
|
||||
# The copy is listed twice and counted once.
|
||||
@@ -210,7 +210,7 @@ class ACopyFiledByEmulatorDoesNotMoveAMachine(unittest.TestCase):
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
db = self._db(tmp)
|
||||
manufacturers = gs._group_by_manufacturer(db)
|
||||
manufacturers = collection._group_by_manufacturer(db)
|
||||
config = {"systems": {"nintendo-nes": {"files": [
|
||||
{"name": "FDS_disksys-nintendo.rom", "sha1": "d" * 40}]}}}
|
||||
pages = places._system_pages_from_data(
|
||||
@@ -227,7 +227,7 @@ class ACopyFiledByEmulatorDoesNotMoveAMachine(unittest.TestCase):
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
db = load_database("database.json")
|
||||
manufacturers = gs._group_by_manufacturer(db)
|
||||
manufacturers = collection._group_by_manufacturer(db)
|
||||
pages = places._system_pages_from_data(
|
||||
manufacturers, {}, db, load_emulator_profiles("emulators", skip_aliases=False))
|
||||
expected = {
|
||||
@@ -295,7 +295,7 @@ class EverySystemLinkLandsOnItsSection(unittest.TestCase):
|
||||
|
||||
db = load_database(str(REPO_ROOT / "database.json"))
|
||||
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"), skip_aliases=False)
|
||||
systemnames.set_console_sections(gs._group_by_manufacturer(db), systemnames.program_names(profiles))
|
||||
systemnames.set_console_sections(collection._group_by_manufacturer(db), systemnames.program_names(profiles))
|
||||
platforms = REPO_ROOT / "platforms"
|
||||
ids = {str(sid) for profile in profiles.values() for sid in profile.get("systems") or []}
|
||||
for name in list_registered_platforms(str(platforms)):
|
||||
|
||||
@@ -20,7 +20,7 @@ from model import systemnames
|
||||
from model.registry import list_registered_platforms
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
from generate_site import _group_by_manufacturer
|
||||
from model.collection import _group_by_manufacturer
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ Reads the repository: skips when the database is absent.
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
from tests.sources import script_source
|
||||
|
||||
import json
|
||||
import os
|
||||
@@ -151,7 +152,7 @@ class SystemLinks(unittest.TestCase):
|
||||
from model.registry import list_registered_platforms
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
from generate_site import _group_by_manufacturer
|
||||
from model.collection import _group_by_manufacturer
|
||||
from sitegen.systempages import arcade_board_sections
|
||||
|
||||
with open("database.json", encoding="utf-8") as handle:
|
||||
@@ -311,7 +312,7 @@ class SearchAliases(unittest.TestCase):
|
||||
class BuildCount(unittest.TestCase):
|
||||
|
||||
def test_generator_prints_the_count(self) -> None:
|
||||
source = (REPO_ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
self.assertIn("link_coverage(", source)
|
||||
self.assertIn("system ids linked", source)
|
||||
|
||||
|
||||
+20
-13
@@ -40,7 +40,8 @@ from unittest import mock
|
||||
import zipfile
|
||||
import json
|
||||
|
||||
import generate_site as gs
|
||||
from model import collection
|
||||
import sitegen
|
||||
from sitegen import cards as sitegen_cards
|
||||
from sitegen import consolecards
|
||||
from sitegen import decorate
|
||||
@@ -304,8 +305,8 @@ class TheSystemsIndexListsConsoles(unittest.TestCase):
|
||||
be known to be under Sony."""
|
||||
|
||||
def test_one_row_per_console_by_its_name(self):
|
||||
gs.reset_console_pages()
|
||||
self.addCleanup(gs.reset_console_pages)
|
||||
siterender.reset_console_pages()
|
||||
self.addCleanup(siterender.reset_console_pages)
|
||||
groups = {
|
||||
"Sony": {"PlayStation": [_sony_file("a.bin", "a")], "PlayStation 2": [_sony_file("b.bin", "b")]},
|
||||
"Other": {"ScummVM": [_sony_file("c.bin", "c")]},
|
||||
@@ -536,7 +537,9 @@ class CardsSayWhichReleaseTheSetMatches(unittest.TestCase):
|
||||
def card(self) -> str:
|
||||
f = {"name": "set.zip", "sha1": "e" * 40, "md5": "e" * 32, "size": 4,
|
||||
"path": str(self.path)}
|
||||
with mock.patch.object(sitegen_cards, "_romset_releases", return_value=self.releases):
|
||||
with mock.patch.object(sitegen_cards, "_romset_releases", return_value=self.releases), \
|
||||
mock.patch.object(consolecards, "_romset_releases", return_value=self.releases), \
|
||||
mock.patch.object(startwith, "_romset_releases", return_value=self.releases):
|
||||
return "\n".join(sitegen_cards._system_file_card(f, _consumers_with_db({})))
|
||||
|
||||
def test_the_matching_releases_as_runs(self) -> None:
|
||||
@@ -557,7 +560,9 @@ class CardsSayWhichReleaseTheSetMatches(unittest.TestCase):
|
||||
|
||||
def test_a_page_of_sets_links_the_version_answer(self) -> None:
|
||||
f = {"name": "set.zip", "sha1": "e" * 40, "path": "bios/SNK/Neo Geo/set.zip"}
|
||||
with mock.patch.object(sitegen_cards, "_romset_releases", return_value=self.releases):
|
||||
with mock.patch.object(sitegen_cards, "_romset_releases", return_value=self.releases), \
|
||||
mock.patch.object(consolecards, "_romset_releases", return_value=self.releases), \
|
||||
mock.patch.object(startwith, "_romset_releases", return_value=self.releases):
|
||||
page = systempages.generate_system_page("SNK", {"Neo Geo": [f]}, _consumers_with_db({}))
|
||||
self.assertIn("MAME and FBNeo sets must match the emulator's version. [Which version "
|
||||
f"each core reads]({sitegen_cards.ROMSET_FAQ}).", page)
|
||||
@@ -653,7 +658,9 @@ class InstallBoxesCountTowardTheSummary(unittest.TestCase):
|
||||
return ["x" * box] if console == "Boxed" else []
|
||||
|
||||
with mock.patch.object(sitegen_install, "_console_install_block", side_effect=install), \
|
||||
mock.patch.object(consolecards, "SYSTEM_SUMMARY_HTML", 50_000):
|
||||
mock.patch.object(systempages, "_console_install_block", side_effect=install), \
|
||||
mock.patch.object(consolecards, "SYSTEM_SUMMARY_HTML", 50_000), \
|
||||
mock.patch.object(systempages, "SYSTEM_SUMMARY_HTML", 50_000):
|
||||
return systempages.system_pages("Maker", self.consoles, _consumers_with_db({}), budget=30_000)
|
||||
|
||||
def test_a_section_with_a_heavy_install_box_moves(self) -> None:
|
||||
@@ -845,7 +852,7 @@ class CardsNameEmulatorsByName(unittest.TestCase):
|
||||
def test_no_built_card_link_reads_an_id(self) -> None:
|
||||
if not (DIST / "systems").is_dir():
|
||||
self.skipTest("site not built")
|
||||
profiles = gs._profiles_on_disk()
|
||||
profiles = collection._profiles_on_disk()
|
||||
bad = set()
|
||||
for page in (DIST / "systems").glob("*/index.html"):
|
||||
for emulator, text in re.findall(
|
||||
@@ -860,7 +867,7 @@ class CardsNameEmulatorsByName(unittest.TestCase):
|
||||
class PartPagesKnowWhereTheyAre(unittest.TestCase):
|
||||
def tearDown(self) -> None:
|
||||
# system_pages records where consoles went, for every later page.
|
||||
gs.reset_console_pages()
|
||||
siterender.reset_console_pages()
|
||||
|
||||
"""6.7: 128 system pages had no parent, parts were "part 3 of 5"."""
|
||||
|
||||
@@ -884,7 +891,7 @@ class PartPagesKnowWhereTheyAre(unittest.TestCase):
|
||||
files = [_game_boy_file(f"rom{i:02}.bin", "0123456789"[i], f"bios/Sony/PlayStation 2/rom{i:02}.bin")
|
||||
for i in range(10)]
|
||||
consumers = _consumers_by_system({})
|
||||
with gs.markup.using("mkdocs"):
|
||||
with sitegen.markup.using("mkdocs"):
|
||||
one = sum(len(line) + 1 for line in sitegen_cards._system_file_card(files[0], consumers))
|
||||
pages = systempages.system_pages("Sony", {"PlayStation 2": files}, consumers, budget=one * 7)
|
||||
parts = [stem for stem in pages if stem != "sony"]
|
||||
@@ -909,7 +916,7 @@ def _consoles(page: str) -> list[str]:
|
||||
class ConsolesFieldNamesMachinesOnce(unittest.TestCase):
|
||||
def tearDown(self) -> None:
|
||||
# system_pages records where consoles went, for every later page.
|
||||
gs.reset_console_pages()
|
||||
siterender.reset_console_pages()
|
||||
|
||||
"""The consoles search field: only machine sections, and a console
|
||||
with a page of its own is that page's, or "dolphin" found Other and
|
||||
@@ -918,14 +925,14 @@ class ConsolesFieldNamesMachinesOnce(unittest.TestCase):
|
||||
def test_no_emulator_folder_is_a_console(self) -> None:
|
||||
for maker in ("Other", "Game Engines"):
|
||||
page = systempages.system_pages(maker, {"dolphin": [_game_boy_file("a.bin", "a")]}, _consumers_by_system({}))
|
||||
self.assertEqual(_consoles(page[gs._slug(maker)][0]), [], maker)
|
||||
self.assertEqual(_consoles(page[collection._slug(maker)][0]), [], maker)
|
||||
|
||||
def test_a_console_with_its_own_page_is_left_to_it(self) -> None:
|
||||
big = [_game_boy_file(f"r{i:02}.bin", "0123456789"[i], f"bios/Sega/Saturn/r{i:02}.bin")
|
||||
for i in range(10)]
|
||||
small = [_game_boy_file("pico.bin", "p", "bios/Sega/Pico/pico.bin")]
|
||||
consumers = _consumers_by_system({})
|
||||
with gs.markup.using("mkdocs"):
|
||||
with sitegen.markup.using("mkdocs"):
|
||||
one = sum(len(line) + 1 for line in sitegen_cards._system_file_card(big[0], consumers))
|
||||
# Sega splits by size. Every Sony console has a page whatever its size.
|
||||
pages = systempages.system_pages("Sega", {"Saturn": big, "Pico": small},
|
||||
@@ -933,7 +940,7 @@ class ConsolesFieldNamesMachinesOnce(unittest.TestCase):
|
||||
self.assertIn("sega-saturn", pages)
|
||||
self.assertEqual(_consoles(pages["sega"][0]), ["Pico"])
|
||||
self.assertEqual(_consoles(pages["sega-saturn"][0]), ["Saturn"])
|
||||
self.addCleanup(gs.reset_console_pages)
|
||||
self.addCleanup(siterender.reset_console_pages)
|
||||
sony = systempages.system_pages("Sony", {"PlayStation": big, "PocketStation": small},
|
||||
consumers, budget=one * 12)
|
||||
self.assertEqual(_consoles(sony["sony"][0]), [])
|
||||
|
||||
@@ -12,6 +12,7 @@ would have its upload flagged by the same project.
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
from tests.sources import script_source
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
@@ -444,7 +445,7 @@ class EveryFolderIsTheReviewsFolder(_World):
|
||||
self.assertEqual(spot.folder, "bios/Maker/Console/")
|
||||
|
||||
def test_the_gaps_page_upload_link_reads_the_same_rule(self):
|
||||
source = (REPO_ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8")
|
||||
source = script_source("generate_site.py")
|
||||
self.assertIn("folder = placer.folder(declared[0]) if placer and declared else \"\"", source)
|
||||
self.assertNotIn("def _upload_folder", source)
|
||||
self.assertEqual(self.placer.folder(self.profiles["engine"]["files"][1]),
|
||||
|
||||
@@ -32,6 +32,7 @@ setup guides or the generator that writes the page a link opens.
|
||||
from __future__ import annotations
|
||||
|
||||
import tests
|
||||
from tests.sources import script_source
|
||||
|
||||
import fnmatch
|
||||
import json
|
||||
@@ -1092,7 +1093,7 @@ class FaqAnswersLeadSomewhere(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.text = _wiki("faq.md")
|
||||
self.generator = (REPO_ROOT / "scripts" / "generate_site.py").read_text(encoding="utf-8")
|
||||
self.generator = script_source("generate_site.py")
|
||||
|
||||
def test_ios_goes_to_the_iphone_section(self):
|
||||
section = _flat(_section(self.text, "A setup is not in the list"))
|
||||
|
||||
@@ -18,7 +18,7 @@ import unittest
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
import sitesources
|
||||
from model import sourceref
|
||||
from sitegen import sources
|
||||
from core import upstream
|
||||
from model.profiles import load_emulator_profiles
|
||||
@@ -109,7 +109,7 @@ class TheSevenProfilesCiteHeldPaths(unittest.TestCase):
|
||||
for _label, refs in source_ref_values(value):
|
||||
for part in split_source_ref(refs):
|
||||
_role, path = ref_role(part.path)
|
||||
if " " in path or sitesources.is_binary_citation(path):
|
||||
if " " in path or sourceref.is_binary_citation(path):
|
||||
continue
|
||||
verdicts = [sources.tree_holds(r, p, path) for r, p in candidates]
|
||||
if None in verdicts:
|
||||
|
||||
Reference in new issue
Block a user