From a1f4a2baa60aadf8424386b7ccb516ec02917d94 Mon Sep 17 00:00:00 2001 From: Brad Barnett <127794626+bdbarnett@users.noreply.github.com> Date: Thu, 8 Oct 2026 12:47:40 -0500 Subject: [PATCH 1/2] Drop workbench's hero_canvas: page=none generates no page to show it The validator now refuses a hero on a page=none entry, so the next one is caught when the database is edited. --- data/repos_db.json | 7 ----- scripts/generate_sites.py | 5 ++++ tests/test_validate_db.py | 55 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 tests/test_validate_db.py diff --git a/data/repos_db.json b/data/repos_db.json index 47a1298..bba8017 100644 --- a/data/repos_db.json +++ b/data/repos_db.json @@ -868,13 +868,6 @@ "eyebrow": "workbench", "headline": "workbench — the browser IDE and MicroPython simulator.", "description": "A ViperIDE fork with a built-in WebAssembly MicroPython simulator: edit, run, and debug PyDevices code against a simulated board entirely in the browser, no hardware required.", - "hero_canvas": { - "app": "polyhedron", - "width": 240, - "height": 240, - "shape": "square", - "app_url": "https://PyDevices.github.io/assets/apps/polyhedron.py" - }, "buttons": [ { "label": "GitHub Repo", diff --git a/scripts/generate_sites.py b/scripts/generate_sites.py index 3376b01..6dd9e7a 100755 --- a/scripts/generate_sites.py +++ b/scripts/generate_sites.py @@ -142,6 +142,11 @@ def validate_db(db, only=None): problems.append( f'{name}: page {destination!r} is not one of {sorted(valid_pages)}' ) + # page=none generates no landing page, so a hero there runs nowhere. + if destination == 'none' and data.get('hero_canvas'): + problems.append( + f'{name}: hero_canvas on page=none; nothing generates a page to show it' + ) # A repo keeping its own Pages must still have somewhere to publish from. if on_disk and destination == 'self' and not os.path.isdir( os.path.join(BASE_DIR, name, '.site') diff --git a/tests/test_validate_db.py b/tests/test_validate_db.py new file mode 100644 index 0000000..9ee69f2 --- /dev/null +++ b/tests/test_validate_db.py @@ -0,0 +1,55 @@ +"""validate_db() catches database entries that generate nothing anyone serves.""" + +from __future__ import annotations + +import copy +import json +import sys +import unittest +from pathlib import Path + +REPO = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(REPO / "scripts")) + +import generate_sites # noqa: E402 + + +def _db() -> dict: + return json.loads((REPO / "data/repos_db.json").read_text(encoding="utf-8")) + + +class HeroCanvasTests(unittest.TestCase): + def setUp(self) -> None: + # The script finds its assets through the workspace layout; a checkout + # anywhere else (a worktree) still has them beside these tests. + saved = generate_sites.ASSETS_DIR + generate_sites.ASSETS_DIR = str(REPO / "assets") + self.addCleanup(setattr, generate_sites, "ASSETS_DIR", saved) + + def _problems(self, db: dict) -> list[str]: + try: + generate_sites.validate_db(db, only="__none__") + except SystemExit as exc: + return [line.strip() for line in str(exc).splitlines()] + return [] + + def test_database_has_no_hero_on_a_page_nobody_generates(self) -> None: + unserved = [ + name for name, data in generate_sites.repos(_db()).items() + if data.get("hero_canvas") and generate_sites.page_destination(data) == "none" + ] + self.assertEqual(unserved, []) + + def test_validator_rejects_a_hero_on_page_none(self) -> None: + db = copy.deepcopy(_db()) + name = next(n for n, d in generate_sites.repos(db).items() if d.get("hero_canvas")) + db[name]["page"] = "none" + problems = self._problems(db) + self.assertTrue( + any(p.startswith(f"{name}: hero_canvas") and "page=none" in p for p in problems), + problems, + ) + + +if __name__ == "__main__": + unittest.main() From 3a2f900e8e653ba1f78903e30c9a98f970aca681 Mon Sep 17 00:00:00 2001 From: Brad Barnett <127794626+bdbarnett@users.noreply.github.com> Date: Thu, 8 Oct 2026 21:47:21 -0500 Subject: [PATCH 2/2] test_validate_db: drop the unused noqa ruff flags --- tests/test_validate_db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_validate_db.py b/tests/test_validate_db.py index 9ee69f2..3fa22b4 100644 --- a/tests/test_validate_db.py +++ b/tests/test_validate_db.py @@ -11,7 +11,7 @@ REPO = Path(__file__).resolve().parents[1] sys.path.insert(0, str(REPO / "scripts")) -import generate_sites # noqa: E402 +import generate_sites def _db() -> dict: