test_smoke_s1.py 1.04 KB
#!/usr/bin/env python3
"""Smoketest: all key pages return 200."""
import subprocess, sys

URLS = [
    ("GET /", "http://127.0.0.1:5000/"),
    ("GET /messages", "http://127.0.0.1:5000/messages"),
    ("GET /articles", "http://127.0.0.1:5000/articles"),
    ("GET /learn", "http://127.0.0.1:5000/learn"),
    ("GET /reports", "http://127.0.0.1:5000/reports"),
    ("GET /dashboard", "http://127.0.0.1:5000/dashboard"),
    ("GET /chat (AI)", "http://127.0.0.1:5000/chat"),
    ("GET /chat/wxid_test", "http://127.0.0.1:5000/chat/wxid_test"),
]
PASS = FAIL = 0
for name, url in URLS:
    r = subprocess.run(["curl", "-s", "-o", "/dev/null", "-w", "%{http_code}",
                        "--connect-timeout", "5", "--max-time", "10", url],
                       capture_output=True, text=True, timeout=15)
    code = r.stdout.strip()
    if code == "200":
        PASS += 1
        print(f"  ✅ {name} → {code}")
    else:
        FAIL += 1
        print(f"  ❌ {name} → {code}")

print(f"\nSmoketest: {PASS}/{PASS+FAIL} passed")
sys.exit(0 if FAIL == 0 else 1)