This commit is contained in:
zlwu committed 2026-05-20 15:10:55 +08:00
1 parent 27ac28b8f5
commit 276299ff27
16 files changed
+3999 -3707

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
"""组织树关键词检索:匹配子节点须带上祖先才能组树。"""
from app.crud.dept import _build_tree, _collect_with_ancestors
def _item(dept_id: str, name: str, parent_id: str = "0") -> dict:
return {
"id": dept_id,
"parentId": parent_id,
"deptName": name,
"orderNum": 0,
}
def test_collect_with_ancestors_includes_parent_chain():
flat = [
_item("root", "市场营销部门"),
_item("child", "采集部", "root"),
]
expanded = _collect_with_ancestors(flat, {"child"})
ids = {x["id"] for x in expanded}
assert ids == {"root", "child"}
def test_build_tree_shows_child_under_parent_after_keyword_expand():
flat = [
_item("root", "市场营销部门"),
_item("child", "采集部", "root"),
]
expanded = _collect_with_ancestors(flat, {"child"})
tree = _build_tree(expanded, "0")
assert len(tree) == 1
assert tree[0]["deptName"] == "市场营销部门"
assert len(tree[0]["children"]) == 1
assert tree[0]["children"][0]["deptName"] == "采集部"
+21
View File
@@ -0,0 +1,21 @@
"""用户列表关键词:须同时匹配账号、昵称、手机号(与 crud.user.list_users 一致)。"""
import inspect
from app.api import admin as admin_api
def test_admin_list_users_keyword_filters_three_fields():
"""回归:admin 路由不得仅按 nick_name 检索。"""
source = inspect.getsource(admin_api.list_users)
assert "SysUser.user_no.like" in source
assert "SysUser.nick_name.like" in source
assert "SysUser.phone_no.like" in source
assert "or_(" in source
def test_admin_list_users_resolves_dept_name():
"""回归:列表须解析 deptName 供所属组织列展示。"""
source = inspect.getsource(admin_api.list_users)
assert "dept_map" in source
assert "_row_to_dict(r, dept_name=" in source