Enrich post list with boundUserNames and open view dialog from the name column. Co-authored-by: Cursor <cursoragent@cursor.com>
29 lines
1001 B
Python
29 lines
1001 B
Python
"""职位列表 boundUserNames enrichment。"""
|
|
import inspect
|
|
|
|
from app.crud import post as post_crud
|
|
|
|
|
|
class _DummySession:
|
|
def query(self, *args, **kwargs): # pragma: no cover
|
|
raise AssertionError("空入参不应访问数据库")
|
|
|
|
|
|
def test_bound_user_names_by_post_ids_empty():
|
|
db = _DummySession()
|
|
assert post_crud._bound_user_names_by_post_ids(db, [], "zkxw") == {}
|
|
assert post_crud._bound_user_names_by_post_ids(db, ["p1"], "") == {}
|
|
|
|
|
|
def test_user_display_name_prefers_nick():
|
|
assert post_crud._user_display_name("张三", "zhangsan") == "张三"
|
|
assert post_crud._user_display_name("", "zhangsan") == "zhangsan"
|
|
assert post_crud._user_display_name(" ", "u1") == "u1"
|
|
assert post_crud._user_display_name(None, None) == ""
|
|
|
|
|
|
def test_list_posts_enriches_bound_user_names():
|
|
source = inspect.getsource(post_crud.list_posts)
|
|
assert "_bound_user_names_by_post_ids" in source
|
|
assert "bound_user_names" in source or "boundUserNames" in source
|