Add approval instance drafts with menu badges, dual-track user/role read model and role bound names, form-designer outline docs, and bare-metal test deploy scripts. Ignore local test-server credential file. Co-authored-by: Cursor <cursoragent@cursor.com>
36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
"""角色列表 boundUserNames / boundPostNames enrichment。"""
|
|
import inspect
|
|
|
|
from app.crud import role as role_crud
|
|
|
|
|
|
class _DummySession:
|
|
def query(self, *args, **kwargs): # pragma: no cover
|
|
raise AssertionError("空入参不应访问数据库")
|
|
|
|
|
|
def test_bound_user_names_by_role_ids_empty():
|
|
db = _DummySession()
|
|
assert role_crud._bound_user_names_by_role_ids(db, [], "zkxw") == {}
|
|
assert role_crud._bound_user_names_by_role_ids(db, ["r1"], "") == {}
|
|
|
|
|
|
def test_bound_post_names_by_role_ids_empty():
|
|
db = _DummySession()
|
|
assert role_crud._bound_post_names_by_role_ids(db, [], "zkxw") == {}
|
|
assert role_crud._bound_post_names_by_role_ids(db, ["r1"], "") == {}
|
|
|
|
|
|
def test_user_display_name_prefers_nick():
|
|
assert role_crud._user_display_name("张三", "zhangsan") == "张三"
|
|
assert role_crud._user_display_name("", "zhangsan") == "zhangsan"
|
|
assert role_crud._user_display_name(" ", "u1") == "u1"
|
|
assert role_crud._user_display_name(None, None) == ""
|
|
|
|
|
|
def test_list_roles_enriches_bound_names():
|
|
source = inspect.getsource(role_crud.list_roles)
|
|
assert "_bound_user_names_by_role_ids" in source
|
|
assert "_bound_post_names_by_role_ids" in source
|
|
assert "boundUserNames" in inspect.getsource(role_crud._row_to_dict) or "bound_user_names" in source
|