fix: place install commands where systems link

system_install_choices and the emulator card's maker read the folder
votes of sitegen.places while every system link read system_section:
Game Boy Color's commands sat under Game Boy, Super A'Can's under
Arcade. Both now read system_section, after the boards are recorded,
and a test checks every command against its system's link.
This commit is contained in:
Abdessamad Derraz committed 2026-11-23 21:44:08 +01:00
1 parent 2971219571
commit 74924be233
9 files changed
+69 -104

No files matched your search

+10 -6
View File
@@ -1224,13 +1224,17 @@ class TheOneLinerIsWhereUsersLand(unittest.TestCase):
from sitegen import cards
from sitegen import render as siterender
saved = dict(siterender.system_page_map)
self.addCleanup(siterender.set_system_page_map, saved)
siterender.set_system_page_map({"sony-playstation": ("sony", "PlayStation"),
"nowhere": ("sony", "PlayStation")})
cov = {"retroarch": {"config": {"systems": {"sony-playstation": {}, "nowhere": {}}}}}
from model import systemnames
systemnames.set_console_sections({("Sony", "PlayStation")})
self.addCleanup(systemnames._sections_installed.__setitem__, 0, False)
siterender.reset_console_pages()
self.addCleanup(siterender.reset_console_pages)
# "playstation" leads to the same section, but the manifest records
# retroarch's own spelling only.
cov = {"retroarch": {"config": {"systems": {"sony-playstation": {}, "playstation": {}}}}}
choices = cards.system_install_choices(cov)
self.assertEqual(choices["sony"]["PlayStation"], [("retroarch", "sony-playstation")])
self.assertEqual(choices, {"sony": {"PlayStation": [("retroarch", "sony-playstation")]}})
class TheGapPageOpensOnCounts(unittest.TestCase):
-26
View File
@@ -81,32 +81,6 @@ class OtherSpellingsOfOneSystem(unittest.TestCase):
self.assertEqual(platformfiles.system_emulators("sega-mega-drive", index), ["genesis_plus_gx"])
self.assertEqual(platformfiles.system_emulators("nintendo-snes", index), [])
def _install(self, mapping: dict) -> None:
from sitegen import render as siterender
saved = dict(siterender.system_page_map)
self.addCleanup(siterender.set_system_page_map, saved)
siterender.set_system_page_map(mapping)
def test_a_profile_spelling_finds_the_platform_page(self):
from sitegen import render as siterender
self._install({"sega-mega-drive": ("sega", "Mega Drive")})
self.assertEqual(siterender.page_by_norm("sega-megadrive"), ("sega", "Mega Drive"))
self._install({"sega-mega-drive": ("sega", "Mega Drive"),
"megadrive": ("other", "Elsewhere")})
self.assertIsNone(siterender.page_by_norm("sega-megadrive"))
def test_a_table_of_the_same_size_replaces_the_other_spellings(self):
"""The index of other spellings was kept while the table kept its
length, so a second table of one entry linked to the first one's page."""
from sitegen import render as siterender
self._install({"sega-mega-drive": ("sega", "Mega Drive")})
self.assertEqual(siterender.page_by_norm("sega-megadrive"), ("sega", "Mega Drive"))
self._install({"sega-mega-drive": ("other", "Elsewhere")})
self.assertEqual(siterender.page_by_norm("sega-megadrive"), ("other", "Elsewhere"))
def test_a_system_only_profiles_name_is_placed_by_their_files(self):
manufacturers = {"Commodore": {"PET": [{"name": "basic4.bin"}]}}
profiles = {"vice_xpet": {"systems": ["commodore-pet"],
+31 -1
View File
@@ -167,12 +167,14 @@ class SystemLinks(unittest.TestCase):
siterender.reset_console_pages()
# The sections as the system pages hold them: each board, the
# sets a reviewed machine owns under that machine.
cls.sections, _installs = arcade_board_sections(cls.manufacturers, {})
cls.sections = arcade_board_sections(cls.manufacturers)
platforms = [
load_platform_config(name, "platforms")
for name in list_registered_platforms("platforms")
]
cls.ids = siterender.system_ids(profiles, platforms)
cls.coverages = {name: {"config": config} for name, config in
zip(list_registered_platforms("platforms"), platforms)}
entries = _entries_by_system(platforms, profiles)
cls.held: dict[str, set[tuple[str, str]]] = _held_sections(
@@ -196,6 +198,34 @@ class SystemLinks(unittest.TestCase):
)
self.assertEqual(plain, [], "link these or name them in UNLINKED with the reason")
def test_install_commands_sit_where_the_system_links(self) -> None:
"""The commands were placed by the folder votes of sitegen.places
and the links by system_section: Game Boy Color's commands sat under
Game Boy, Super A'Can's under Arcade, while their links led to their
own sections."""
from sitegen.cards import system_install_choices
from sitegen.install import manifest_systems
placed = {
(platform, sys_id): (slug, console)
for slug, consoles in system_install_choices(self.coverages).items()
for console, pairs in consoles.items()
for platform, sys_id in pairs
}
wrong = sorted(
(pair, place, siterender.system_section(pair[1]))
for pair, place in placed.items()
if siterender.system_section(pair[1]) != place
)
self.assertEqual(wrong, [])
unplaced = sorted(
(name, sys_id)
for name, cov in self.coverages.items()
for sys_id in set(cov["config"].get("systems") or {}) & manifest_systems(name)
if siterender.system_section(sys_id) and (name, sys_id) not in placed
)
self.assertEqual(unplaced, [])
def test_unlinked_list_is_current(self) -> None:
stale = sorted(
sys_id for sys_id in UNLINKED