mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-02 06:18:51 -06:00
Fifteen modules imported FakeRepository from test_install_selection, and others read fixtures from test_install_app, test_install_offline, test_install_games, test_launchers, test_prose_style, test_site_nav, test_site_pronouns and test_site_copy. Those now live in installsupport, gamessupport, launcherssupport, docpagessupport, sitepages and sitecopy, and test_layers refuses an import of a test module. sitereferencesupport and the DIST each site module defined merge into sitepages, launchersretrobatsupport into launcherssupport, auditsupport into the tests package (REPO_ROOT, HAS_JSONSCHEMA). test_launchers is the Batocera module and becomes test_launchers_batocera. test_port becomes test_handheld_port: its archive checks repeated test_handheld_scripts, whose TheArchives now holds the port.json assertions. The testing guide splits the row that held 113 modules, replaces the e2e number ranges by a module table, gives package imports and scratch_dir in How to add a test, lists every module that reads the working tree and every helper module. Its guard moves to test_doc_pages_tools and checks each module on one row once and each family on one row. The guide and tools.md join the pages whose cited paths and options are looked up.
97 lines
4.0 KiB
Python
97 lines
4.0 KiB
Python
"""The drawn steps of the install box (scripts/sitesteps.py).
|
|
|
|
Each drawing file says in words what it shows, for one opened on its own:
|
|
a title and a desc the SVG names. On the page the images are alt="" and the
|
|
text above them is the one reading (tests/test_site_page_text.py). The
|
|
drawing tells the same steps as that text, the keys included, so the picture
|
|
and the words never disagree. And it draws in the theme's colours.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import tests
|
|
from tests.sitepages import DIST
|
|
|
|
import re
|
|
import unittest
|
|
import xml.etree.ElementTree as ET
|
|
from pathlib import Path
|
|
|
|
from sitegen import diagrams
|
|
from sitegen import steps as sitesteps
|
|
from sitegen.guidedata import terminals
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
|
|
SVG = "{http://www.w3.org/2000/svg}"
|
|
|
|
|
|
class EachDrawingNamesItsSteps(unittest.TestCase):
|
|
def test_title_and_desc_are_what_aria_points_at(self):
|
|
for tab in sitesteps.STEPS:
|
|
for layout in ("wide", "narrow"):
|
|
root = ET.fromstring(sitesteps._svg(tab, layout))
|
|
with self.subTest(tab=tab, layout=layout):
|
|
self.assertEqual(root.get("role"), "img")
|
|
title, desc = root.find(f"{SVG}title"), root.find(f"{SVG}desc")
|
|
self.assertIsNotNone(title)
|
|
self.assertIsNotNone(desc)
|
|
self.assertEqual(root.get("aria-labelledby").split(),
|
|
[title.get("id"), desc.get("id")])
|
|
self.assertEqual(desc.text, sitesteps.description(tab))
|
|
|
|
def test_every_caption_drawn_is_in_the_desc(self):
|
|
for tab, (_title, steps) in sitesteps.STEPS.items():
|
|
desc = sitesteps.description(tab)
|
|
for step in steps:
|
|
with self.subTest(tab=tab, step=step.caption):
|
|
self.assertIn(step.caption, desc)
|
|
|
|
def test_the_drawing_and_the_text_name_the_same_keys(self):
|
|
for tab, (_title, steps) in sitesteps.STEPS.items():
|
|
text = terminals()[tab][1].replace("**", "")
|
|
keys = {step.word for step in steps if step.icon == "keys"}
|
|
with self.subTest(tab=tab):
|
|
for word in keys:
|
|
self.assertIn(word, text)
|
|
drawn = set(re.findall(r"\b(?:Ctrl|Cmd|Shift|Alt)\+\w+(?:\+\w+)?", text))
|
|
self.assertLessEqual(drawn, keys)
|
|
self.assertIn("Click Copy", text)
|
|
|
|
def test_one_drawing_per_computer_tab_none_elsewhere(self):
|
|
self.assertEqual(set(sitesteps.STEPS), {"windows", "macos", "linux", "steamdeck"})
|
|
self.assertEqual(sitesteps.steps_figure("device"), [])
|
|
|
|
def test_colours_come_from_the_theme(self):
|
|
for tab in sitesteps.STEPS:
|
|
root = ET.fromstring(sitesteps._svg(tab, "wide"))
|
|
for node in root.iter():
|
|
tag = node.tag.removeprefix(SVG)
|
|
if tag in ("rect", "path", "circle"):
|
|
with self.subTest(tab=tab, node=ET.tostring(node)[:60]):
|
|
self.assertTrue(node.get("class", "").startswith("rb-d-"))
|
|
|
|
def test_ids_are_unique_on_the_page(self):
|
|
ids = re.findall(r'id="([^"]+)"', "".join(
|
|
sitesteps._svg(tab, layout) for tab in sitesteps.STEPS for layout in ("wide", "narrow")))
|
|
self.assertEqual(len(ids), len(set(ids)))
|
|
|
|
|
|
class TheBuiltPageHoldsThem(unittest.TestCase):
|
|
def test_under_each_tab_of_get_your_files(self):
|
|
page = DIST / "which-pack" / "index.html"
|
|
if not page.is_file():
|
|
self.skipTest("no built site")
|
|
html = page.read_text(encoding="utf-8")
|
|
for tab in sitesteps.STEPS:
|
|
for layout in ("wide", "narrow"):
|
|
for theme in diagrams.THEMES:
|
|
name = f"{sitesteps.stem(tab)}-{layout}-{theme}.svg"
|
|
with self.subTest(file=name):
|
|
self.assertIn(f"/retrobios/{diagrams.DIAGRAM_DIR}/{name}", html)
|
|
self.assertTrue((DIST / diagrams.DIAGRAM_DIR / name).is_file())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|