test_s3_nav_integration.py
2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3
"""S3 test: Agents nav integration + smoketest update."""
import json, sys, subprocess
BASE = "http://127.0.0.1:5001"
passed = 0
failed = 0
def curl(path):
cmd = ["curl", "-s", "-w", "\n%{http_code}", f"{BASE}{path}"]
r = subprocess.run(cmd, capture_output=True, text=True, timeout=15)
parts = r.stdout.rsplit("\n", 1)
body = parts[0] if len(parts) > 1 else r.stdout
code = int(parts[1]) if len(parts) > 1 else 0
return code, body
# TC1: /skills page HTML contains "agents" nav link
code, html = curl("/skills")
if code == 200 and "/agents" in html:
passed += 1
print(f" PASS /skills HTML has /agents nav link")
else:
failed += 1
print(f" FAIL /skills HTML: code={code}, agents_nav={('/agents' in html)}")
# TC2: /agents page HTML contains "agents" nav link (active state)
code, html = curl("/agents")
if code == 200 and "agents" in html.lower():
passed += 1
print(f" PASS /agents HTML has agents nav reference")
else:
failed += 1
print(f" FAIL /agents HTML: code={code}")
# TC3: smoketest includes /agents test
r = subprocess.run(["python3", "test_smoke.py"], capture_output=True, text=True, timeout=60, cwd=".")
smoke_out = r.stdout + r.stderr
if "agents" in smoke_out.lower() and "10/10" in smoke_out:
passed += 1
print(f" PASS smoketest includes /agents: 10/10 found")
elif "agents" in smoke_out.lower():
passed += 1
print(f" PASS smoketest includes /agents reference")
else:
failed += 1
print(f" FAIL smoketest missing /agents test. Output: {smoke_out[:200]}")
# TC4: All existing pages still return 200 (regression)
pages = ["/", "/articles", "/skills", "/reports", "/learn", "/cron", "/agents", "/agent/default"]
all_ok = True
for p in pages:
code, _ = curl(p)
if code != 200:
all_ok = False
print(f" FAIL {p}: HTTP {code}")
if all_ok:
passed += 1
print(f" PASS All {len(pages)} pages return 200")
else:
failed += 1
print(f" FAIL Some pages not 200")
print(f"\n{passed}/{passed+failed} 通过")
sys.exit(0 if failed == 0 else 1)