mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 14:50:45 +00:00
修管理页测试的引号敏感 + 补 netPanel id
重做管理页时把 HTML 从 class=pick(无引号)改成了 class="pick"(标准写法),但测试里写死了无引号形式, 于是 5 个断言集体误报失败。 HTML 两种写法都合法,测试不该关心这个 —— 给两个测试加了 _has(),带不带引号都认。 另外给新管理页的体检卡补回 id=netPanel(语义合理, 也顺手让测试钩子还在)。 同时删掉 _build/_missing_tail.py(恢复事故时的临时文件, 静态检查把它当成真模块查,报了 8 个 undefined name)。 验证:管理页网络体检 15/15、中转批量删除 24/24、 全局 32 个阶段全部通过。
This commit is contained in:
@@ -25,6 +25,23 @@ passed = 0
|
||||
failed = 0
|
||||
|
||||
|
||||
def _has(html: str, token: str) -> bool:
|
||||
"""判断 html 里有没有这个属性,**带不带引号都算**。
|
||||
|
||||
旧版页面写的是 class=pick(无引号),
|
||||
重做后改成了标准的 class="pick"(带引号)。
|
||||
测试不该因为引号差异就报失败 —— HTML 两种都合法。
|
||||
"""
|
||||
if token in html:
|
||||
return True
|
||||
# class=pick -> class="pick" / id=netBtn -> id="netBtn"
|
||||
match = re.match(r"^([A-Za-z-]+)=(.+)$", token)
|
||||
if not match:
|
||||
return False
|
||||
attr, value = match.group(1), match.group(2)
|
||||
return ('%s="%s"' % (attr, value)) in html
|
||||
|
||||
|
||||
def check(name, ok, detail=""):
|
||||
global passed, failed
|
||||
if ok:
|
||||
@@ -127,8 +144,8 @@ def main() -> int:
|
||||
print("三、管理页上有这张卡片")
|
||||
html = opener.open(urllib.request.Request(BASE + "/zhongzhuanzhan", headers=UA),
|
||||
timeout=10).read().decode("utf-8")
|
||||
check("有网络体检面板", 'id=netPanel' in html, "")
|
||||
check("有「测一下」按钮", 'id=netBtn' in html, "")
|
||||
check("有网络体检面板", _has(html, "id=netPanel"), "")
|
||||
check("有「测一下」按钮", _has(html, "id=netBtn"), "")
|
||||
check("JS 里调 netcheck 接口", "/v1/admin/netcheck" in html, "")
|
||||
check("会显示隧道连接数", "tunnelConnections" in html, "")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user