4ea0e88c98
- 新增中心联系人展示名解析服务,支持从逗号分隔用户 ID 解析姓名\n- 中心列表接口返回 contact_display,避免前端依赖项目成员权限才能展示联系人姓名\n- 中心管理和立项会议授权页面优先使用后端联系人展示名\n- 补充联系人解析服务测试和立项会议授权页面展示顺序测试
41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
import uuid
|
|
|
|
import pytest
|
|
|
|
from app.models.user import User
|
|
from app.services.site_contact_display import build_contact_display
|
|
|
|
|
|
def make_user(user_id: uuid.UUID, full_name: str, email: str) -> User:
|
|
return User(
|
|
id=user_id,
|
|
email=email,
|
|
password_hash="hash",
|
|
full_name=full_name,
|
|
clinical_department="PMO",
|
|
)
|
|
|
|
|
|
def test_build_contact_display_resolves_comma_separated_user_ids():
|
|
first_id = uuid.uuid4()
|
|
second_id = uuid.uuid4()
|
|
users = {
|
|
first_id: make_user(first_id, "张三", "zhangsan@example.com"),
|
|
second_id: make_user(second_id, "李四", "lisi@example.com"),
|
|
}
|
|
|
|
display = build_contact_display(f"{first_id}, {second_id}", users)
|
|
|
|
assert display == "张三、李四"
|
|
|
|
|
|
@pytest.mark.parametrize("role", ["PM", "CRA", "PV", "QA", "CTA"])
|
|
def test_build_contact_display_is_role_independent_for_site_read_roles(role: str):
|
|
user_id = uuid.uuid4()
|
|
users = {user_id: make_user(user_id, "周成", "zhoucheng@example.com")}
|
|
|
|
display = build_contact_display(str(user_id), users)
|
|
|
|
assert role
|
|
assert display == "周成"
|