no message

This commit is contained in:
hajimi
2026-06-22 01:31:20 +08:00
parent 9994c71374
commit ee9a5a3d03
9 changed files with 112 additions and 14 deletions
+16 -8
View File
@@ -23,7 +23,7 @@ def main() -> None:
assert MENU_SQL.is_file(), f"missing menu seed file: {MENU_SQL}"
menu_sql = MENU_SQL.read_text(encoding="utf-8")
normalized_menu_sql = " ".join(menu_sql.split())
first_insert_block = menu_sql.split(";", 1)[0] + ";"
first_insert_block = "INSERT INTO `la_system_menu`" + menu_sql.split("INSERT INTO `la_system_menu`", 1)[1].split(";", 1)[0] + ";"
normalized_first_insert = " ".join(first_insert_block.split())
assert MATCH_LIVE_PAGE.is_file(), f"missing page file: {MATCH_LIVE_PAGE}"
@@ -111,8 +111,8 @@ def main() -> None:
"match.matchLive/detail",
"match.matchLive/add",
"match.matchLive/edit",
"match.match/lists",
"match.matchLive/delete",
"/match/lists",
):
assert needle in menu_sql, f"{MENU_SQL} missing permission token: {needle}"
@@ -127,20 +127,28 @@ def main() -> None:
assert (
"FROM `la_system_menu` parent" in menu_sql
and "parent.`perms` = 'match.match/lists'" in menu_sql
), f"{MENU_SQL} must bind the match live menu to parent match.match/lists explicitly"
and "parent.`type` = 'M'" in menu_sql
and "parent.`paths` = 'match'" in menu_sql
), f"{MENU_SQL} must bind the match live menu to the top-level match catalogue explicitly"
assert (
"SELECT parent.`id`, 'C', '直播线路管理'" in menu_sql
), f"{MENU_SQL} must insert the page menu only when the parent match.match/lists record exists"
), f"{MENU_SQL} must insert the page menu only when the parent match catalogue record exists"
assert (
"WHERE parent.`perms` = 'match.match/lists' AND NOT EXISTS (" in normalized_first_insert
), f"{MENU_SQL} first insert must combine parent binding with AND NOT EXISTS in a single WHERE predicate"
"WHERE parent.`type` = 'M' AND parent.`paths` = 'match' AND NOT EXISTS (" in normalized_first_insert
), f"{MENU_SQL} first insert must combine top-level match catalogue binding with AND NOT EXISTS in a single WHERE predicate"
assert (
"WHERE parent.`perms` = 'match.match/lists' WHERE NOT EXISTS (" not in normalized_first_insert
"WHERE parent.`type` = 'M' AND parent.`paths` = 'match' WHERE NOT EXISTS (" not in normalized_first_insert
), f"{MENU_SQL} first insert must not contain a second standalone WHERE NOT EXISTS after the parent WHERE"
assert normalized_first_insert.count("WHERE") == 2, (
f"{MENU_SQL} first insert should only have the outer WHERE plus the nested WHERE inside NOT EXISTS"
)
assert "UPDATE `la_system_menu` child" in menu_sql, f"{MENU_SQL} must repair existing live menu parent records"
assert "child.`perms` = 'match.matchLive/index'" in normalized_menu_sql, (
f"{MENU_SQL} must target the existing match.matchLive/index menu when repairing the parent node"
)
assert "child.`pid` <> parent.`id`" in normalized_menu_sql, (
f"{MENU_SQL} repair statement must only move the live menu when it is attached to the wrong parent"
)
assert (
"SELECT (SELECT `id` FROM `la_system_menu` WHERE `perms` = 'match.matchLive/index' LIMIT 1)" in normalized_menu_sql
), f"{MENU_SQL} child permissions must bind to the inserted match.matchLive/index menu"