fix: hold the site tests to Sony console pages

Tests that built a maker's page with sections used Sony, which now gives each console a page: they use Sega, which keeps its sections. A Sony fixture split by console leaked its recorded pages into the index tests that followed. Built-page checks read the cards on the console pages and the opening lines on the Sony summary.
This commit is contained in:
Abdessamad Derraz committed 2026-11-04 04:21:26 +01:00
1 parent 531edaa1ad
commit 36788a3cac
4 files changed
+22 -13

No files matched your search

+1 -1
View File
@@ -289,7 +289,7 @@ class BuiltPagesReadInFewerWords(unittest.TestCase):
def test_a_built_card_holds_its_hashes(self) -> None:
if not (DIST / "systems").is_dir():
self.skipTest("no built site")
main = _main("systems/sony")
main = _main("systems/sony-playstation-portable")
card = main[main.index('id="sha1-30a33f3651f8"'):]
card = card[:card.index('class="rb-sys-file"')]
self.assertRegex(card, r'<dd class="rb-hash">30a33f3651f8</dd>')
+8 -5
View File
@@ -128,8 +128,9 @@ class TheConsoleBiosComesFirst(unittest.TestCase):
self.assertEqual(gs._start_with([_file("a.bin", "a")], _consumers({})), [])
def test_the_page_carries_the_line_under_the_console(self):
page = gs.generate_system_page("Sony", {"PlayStation": self.files}, self.required_only())
heading = page.index("## PlayStation")
# Sega keeps its consoles as sections; Sony gives each a page.
page = gs.generate_system_page("Sega", {"Saturn": self.files}, self.required_only())
heading = page.index("## Saturn")
self.assertLess(heading, page.index("**Start with**"))
self.assertLess(page.index("**Start with**"), page.index('class="rb-sys-file"'))
@@ -149,7 +150,7 @@ class ThePermalinkIsAnIcon(unittest.TestCase):
def test_the_page_draws_the_icon_once(self):
page = gs.generate_system_page(
"Sony", {"PlayStation": [_file("a.bin", "a"), _file("b.bin", "b")]},
"Sega", {"Saturn": [_file("a.bin", "a"), _file("b.bin", "b")]},
FileConsumers({"files": {}}))
self.assertEqual(page.count('<symbol id="rb-link-icon"'), 1)
self.assertEqual(page.count('href="#rb-link-icon"'), 2)
@@ -192,7 +193,7 @@ class TheCardLinesSayWhatTheyMean(unittest.TestCase):
self.assertEqual(folds, ["<details data-pagefind-ignore>"])
def test_the_page_defines_both_lines(self):
page = gs.generate_system_page("Sony", {"PlayStation": [_file("scph5501.bin", "4")]},
page = gs.generate_system_page("Sega", {"Saturn": [_file("scph5501.bin", "4")]},
self.consumers)
key = page.index("**On the setup's list** names")
self.assertLess(key, page.index('class="rb-sys-file"'))
@@ -294,7 +295,9 @@ class TheBuiltSonyPage(unittest.TestCase):
self.text = (DIST / "systems" / "sony" / "index.html").read_text(encoding="utf-8")
def test_no_card_title_says_permalink(self):
titles = re.findall(r'<h3[^>]*class="rb-file-title".*?</h3>', self.text, re.S)
# Every Sony console has a page of its own: the cards are there.
own = (DIST / "systems" / "sony-playstation" / "index.html").read_text(encoding="utf-8")
titles = re.findall(r'<h3[^>]*class="rb-file-title".*?</h3>', own, re.S)
self.assertTrue(titles)
for title in titles:
self.assertNotIn("permalink", re.sub(r"<[^>]+>", "", title))
+11 -6
View File
@@ -282,17 +282,22 @@ class ConsolesFieldNamesMachinesOnce(unittest.TestCase):
self.assertEqual(_consoles(page[gs._slug(maker)][0]), [], maker)
def test_a_console_with_its_own_page_is_left_to_it(self) -> None:
big = [_file(f"r{i:02}.bin", "0123456789"[i], f"bios/Sony/PlayStation/r{i:02}.bin")
big = [_file(f"r{i:02}.bin", "0123456789"[i], f"bios/Sega/Saturn/r{i:02}.bin")
for i in range(10)]
small = [_file("pocket.bin", "p", "bios/Sony/PocketStation/pocket.bin")]
small = [_file("pico.bin", "p", "bios/Sega/Pico/pico.bin")]
consumers = _consumers({})
with gs.markup.using("mkdocs"):
one = sum(len(line) + 1 for line in gs._system_file_card(big[0], consumers))
pages = gs.system_pages("Sony", {"PlayStation": big, "PocketStation": small},
# Sega splits by size; every Sony console has a page whatever its size.
pages = gs.system_pages("Sega", {"Saturn": big, "Pico": small},
consumers, budget=one * 12)
self.assertIn("sony-playstation", pages)
self.assertEqual(_consoles(pages["sony"][0]), ["PocketStation"])
self.assertEqual(_consoles(pages["sony-playstation"][0]), ["PlayStation"])
self.assertIn("sega-saturn", pages)
self.assertEqual(_consoles(pages["sega"][0]), ["Pico"])
self.assertEqual(_consoles(pages["sega-saturn"][0]), ["Saturn"])
sony = gs.system_pages("Sony", {"PlayStation": big, "PocketStation": small},
consumers, budget=one * 12)
self.assertEqual(_consoles(sony["sony"][0]), [])
self.assertEqual(_consoles(sony["sony-pocketstation"][0]), ["PocketStation"])
class OneLineBeforeTheFirstConsole(unittest.TestCase):
+2 -1
View File
@@ -189,7 +189,8 @@ class GateQueries(unittest.TestCase):
"3ds bios": (("systems/nintendo-3ds/",), 1),
"playstation bios": (("systems/sony-playstation/",), 1),
"playstation 2 bios": (("systems/sony-playstation-2/",), 1),
"playstation 3 bios": (("systems/sony/",), 1),
"playstation 3 bios": (("systems/sony-playstation-3/",), 2),
"ps3 bios": (("systems/sony-playstation-3/",), 1),
"game boy advance bios": (("systems/nintendo/",), 1),
"game boy color bios": (("systems/nintendo/",), 1),
"nintendo ds bios": (("systems/nintendo-nintendo-ds/",), 1),