"""Python templates must stay valid Python before their placeholders are filled.""" import re import shutil import subprocess from pathlib import Path import pytest ROOT = Path(__file__).resolve().parents[1] HOOK_RULES = "E9,F63,F7,F82,F811" # same rule set as the PostToolUse lint hook @pytest.mark.parametrize("template", ["rpa-dashboard-no-ai/templates/bridge.py", "rpa-dashboard-no-ai/templates/bot_runner.py"]) def test_template_passes_lint_hook_unfilled(template): ruff = shutil.which("ruff") or pytest.skip("ruff not on PATH") r = subprocess.run([ruff, "check", "--select", HOOK_RULES, "--no-cache", str(ROOT / template)], capture_output=True, text=True) assert r.returncode == 0, r.stdout def test_tebra_sky_preset_is_the_template_default(): templates = ROOT / "rpa-dashboard-no-ai" / "templates" themes = (templates / "themes.md").read_text(encoding="utf-8") sky = themes.split("## 1. Tebra Sky")[1].split("```css\n")[1].split("```")[0] assert sky in (templates / "dashboard.html").read_text(encoding="utf-8") def test_ai_skill_references_files_that_exist(): skill = ROOT / "rpa-dashboard-ai" text = (skill / "SKILL.md").read_text(encoding="utf-8") paths = re.findall(r"`((?:templates/|)[\w./-]+)`", text) assert len(paths) > 5 missing = [p for p in paths if not (skill / p.replace("", "../rpa-dashboard-no-ai/templates/")).exists()] assert not missing