test_lac_integration.py file-level

at main · View file ↗ · Intel ↗

History
1 files
1 commits
0 hotspots
0 🧊 dead
0 💥 blast risk
sha256:6 fix(ISR): default require_independent_second_reviewer to require Opera… · aaronrene · Sep 2, 2026
1 """Integration tests — Landing + access clarity (§LAC.12)."""
2
3 from __future__ import annotations
4
5 import urllib.request
6 from pathlib import Path
7
8 from tests.fixtures.app import seed_app_repo, start_test_app
9 from tools.landing.validate import validate_landing
10
11 KIT_ROOT = Path(__file__).resolve().parents[2]
12
13
14 def test_validate_landing_on_kit_root_passes() -> None:
15 result = validate_landing(KIT_ROOT)
16 assert result.ok, result.errors
17
18
19 def test_relative_doc_links_exist() -> None:
20 index = (KIT_ROOT / "docs" / "landing" / "index.html").read_text(encoding="utf-8")
21 assert "https://github.com/aaronrene/overseer-kit/blob/main/docs/GIT-ONLY-QUICKSTART.md" in index
22 assert "https://github.com/aaronrene/overseer-kit/blob/main/docs/CONSUMER-ADAPTER-PATTERN.md" in index
23 assert "https://github.com/aaronrene/overseer-kit/blob/main/docs/TRACK-Q-DESKTOP-OPERATOR-RUNBOOK.md" in index
24 assert "K7-DOGFOOD-OPERATOR-RUNBOOK" not in index
25 assert (KIT_ROOT / "docs" / "TRACK-Q-DESKTOP-OPERATOR-RUNBOOK.md").is_file()
26 assert "../GIT-ONLY-QUICKSTART.md" not in index
27 assert "musehub.ai" not in index
28 assert "Knowtation" not in index
29 assert "Scooling" not in index
30 assert "VideoFactory" not in index
31
32
33 def test_api_health_returns_repo_root_with_bearer(tmp_path: Path) -> None:
34 seed_app_repo(tmp_path)
35 handle, client = start_test_app(tmp_path)
36 try:
37 status, health = client.get("/api/health")
38 assert status == 200
39 assert health["ok"] is True
40 assert health["result"]["repo_root"] == str(tmp_path.resolve())
41 assert health["result"]["bind"] == "127.0.0.1"
42 assert isinstance(health["result"]["port"], int)
43 finally:
44 handle.shutdown()
45
46
47 def test_path_b_static_still_serves(tmp_path: Path) -> None:
48 seed_app_repo(tmp_path)
49 handle, client = start_test_app(tmp_path)
50 try:
51 request = urllib.request.Request(
52 f"{client.base_url}/",
53 headers={"Authorization": f"Bearer {client.session}"},
54 )
55 with urllib.request.urlopen(request, timeout=5) as response:
56 assert response.status == 200
57 html = response.read().decode("utf-8")
58 assert "Open the local console" in html
59 assert 'id="auth-panel"' in html
60 assert 'id="bound-repo"' in html
61 assert "collapseAuthPanel" in (
62 Path(__file__).resolve().parents[2]
63 / "tools"
64 / "app"
65 / "static"
66 / "assets"
67 / "app.js"
68 ).read_text(encoding="utf-8")
69 finally:
70 handle.shutdown()
71
72
73 def test_unknown_api_still_rejected(tmp_path: Path) -> None:
74 seed_app_repo(tmp_path)
75 handle, client = start_test_app(tmp_path)
76 try:
77 status, payload = client.get("/api/not-a-real-route")
78 assert status == 404
79 assert payload["ok"] is False
80 finally:
81 handle.shutdown()