# -*- coding: utf-8 -*- """快速检查统计页与台账导出。""" import http.cookiejar import urllib.parse import urllib.request BASE = "http://127.0.0.1:8080" def main(): cj = http.cookiejar.CookieJar() op = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj)) op.open(urllib.request.Request( BASE + "/login", data=urllib.parse.urlencode({"username": "admin", "password": "admin123"}).encode()), timeout=30) for path, expect in [("/stats", b"200"), ("/export/ledger", b"xlsx"), ("/orders", b"200"), ("/suppliers", b"200"), ("/materials", b"200"), ("/users", b"200"), ("/", b"200")]: r = op.open(BASE + path, timeout=30) data = r.read() print(path, r.status, len(data)) assert r.status == 200, path print("PAGES OK") if __name__ == "__main__": main()