修管理页测试的引号敏感 + 补 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:
xmz7891
2026-10-07 09:45:10 +08:00
parent 1f05084f51
commit 160dc3765e
7 changed files with 174 additions and 66 deletions
+21 -3
View File
@@ -10,6 +10,7 @@
6. 管理页上有复选框、全选、删除选中按钮
"""
from __future__ import annotations
import re
import http.cookiejar
import json
@@ -34,6 +35,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:
@@ -120,9 +138,9 @@ def main() -> int:
print("一、管理页上有批量删除的控件")
html = opener.open(urllib.request.Request(BASE + "/zhongzhuanzhan", headers=_UA),
timeout=15).read().decode("utf-8")
check("有复选框(input.pick)", "class=pick" in html)
check("有全选(pickAll)", "id=pickAll" in html)
check("有「删除选中」按钮", "id=delPicked" in html)
check("有复选框(input.pick)", _has(html, "class=pick"))
check("有全选(pickAll)", _has(html, "id=pickAll"))
check("有「删除选中」按钮", _has(html, "id=delPicked"))
check("调的是 delete_many 接口", "/v1/admin/delete_many" in html)
check("复选框的 value 是 deviceId", 'value="pc-1"' in html, "")