from __future__ import annotations import json from quantum_learning import ( canonical_course_steps, entry_notebook_path, project_root, reference_notebook_path, visible_notebook_root_names, ) def _notebook_text(path): data = json.loads(path.read_text()) return "\n".join("".join(cell.get("source", [])) for cell in data.get("cells", [])) def test_start_here_is_the_only_supported_entrypoint(): assert entry_notebook_path() == project_root() / "notebooks" / "START_HERE.ipynb" app_script = (project_root() / "scripts" / "app.sh").read_text() assert "lab/tree/notebooks/START_HERE.ipynb" in app_script def test_visible_notebook_root_is_curated(): notebook_root = project_root() / "notebooks" visible_names = sorted(path.name for path in notebook_root.iterdir() if not path.name.startswith(".")) assert visible_names == sorted(visible_notebook_root_names()) def test_reference_notebook_is_not_in_root(): assert reference_notebook_path().exists() assert not (project_root() / "notebooks" / "PROFESSIONAL_PATH.ipynb").exists() def test_mainline_course_notebooks_have_navigation_guardrails(): steps = canonical_course_steps() for index, step in enumerate(steps): path = project_root() / step.path text = _notebook_text(path) assert "" in text assert "" in text assert "What To Open Next" in text if index == 0: assert "This is the start of the mainline course" in text if index < len(steps) - 1: next_title = steps[index + 1].title assert next_title in text else: assert "This notebook closes the mainline course" in text