test_landing_large_html.py python
58 lines 2.1 KB
Raw
sha256:4671b7f787ddbe63ced31c895b688c77ab495653b65a730b423329f26b3c1439 feat: K1-P1 complete — agent provenance, build-verification… Sonnet 4.6 patch 54 days ago
1 """Stress tests — landing validator on large HTML payloads."""
2
3 from __future__ import annotations
4
5 import time
6 from pathlib import Path
7
8 from tools.landing.validate import validate_landing
9
10 KIT_ROOT = Path(__file__).resolve().parents[2]
11
12
13 def test_validator_large_padded_html_bounded(tmp_path: Path) -> None:
14 """Duplicate landing tree with padded HTML; validator must finish without OOM."""
15 landing_src = KIT_ROOT / "docs" / "landing"
16 landing_dst = tmp_path / "docs" / "landing"
17 landing_dst.mkdir(parents=True)
18
19 # Stub linked doc targets referenced from landing pages.
20 linked = [
21 "README.md",
22 "docs/GIT-ONLY-QUICKSTART.md",
23 "docs/CONSUMER-ADAPTER-PATTERN.md",
24 "docs/K7-DOGFOOD-OPERATOR-RUNBOOK.md",
25 "docs/ROADMAP.md",
26 "docs/PHASE-K12-TRACK-N-LANDING-CONTRACT.md",
27 "docs/consumers/videofactory/OVERSEER-SETUP.md",
28 ".github/workflows/freeze-review.yml",
29 ]
30 for rel in linked:
31 path = tmp_path / rel
32 path.parent.mkdir(parents=True, exist_ok=True)
33 path.write_text("# stub\n", encoding="utf-8")
34
35 for rel in ("manifest.yaml", "index.html", "assets/style.css"):
36 src = landing_src / rel
37 dst = landing_dst / rel
38 dst.parent.mkdir(parents=True, exist_ok=True)
39 content = src.read_text(encoding="utf-8")
40 if rel.endswith(".html"):
41 content = content.replace("</body>", "<!-- " + ("x" * 500_000) + " --></body>")
42 dst.write_text(content, encoding="utf-8")
43
44 scenarios_dst = landing_dst / "scenarios" / "index.html"
45 scenarios_dst.parent.mkdir(parents=True, exist_ok=True)
46 scenarios_dst.write_text(
47 (landing_src / "scenarios" / "index.html").read_text(encoding="utf-8"),
48 encoding="utf-8",
49 )
50 (tmp_path / "LICENSE").write_text((KIT_ROOT / "LICENSE").read_text(encoding="utf-8"))
51 (tmp_path / "SECURITY.md").write_text((KIT_ROOT / "SECURITY.md").read_text(encoding="utf-8"))
52
53 start = time.monotonic()
54 result = validate_landing(tmp_path)
55 elapsed = time.monotonic() - start
56
57 assert result.ok, result.errors
58 assert elapsed < 2.0
File History 1 commit
sha256:4671b7f787ddbe63ced31c895b688c77ab495653b65a730b423329f26b3c1439 feat: K1-P1 complete — agent provenance, build-verification… Sonnet 4.6 patch 54 days ago