清理全局角色残留并修复项目权限判断

This commit is contained in:
Cheng Zhou
2026-05-29 10:20:42 +08:00
parent 63457aab11
commit 44d69c2d7b
63 changed files with 739 additions and 443 deletions
+5 -5
View File
@@ -6,17 +6,17 @@ import pytest
from app.api.v1 import studies as studies_api
from app.models.study import Study
from app.models.study_member import StudyMember
from app.models.user import User, UserRole, UserStatus
from app.models.user import User, UserStatus
def _make_user(role: UserRole = UserRole.CRA) -> User:
def _make_user(*, is_admin: bool = False) -> User:
return User(
id=uuid.uuid4(),
email="cra-pm@test.com",
password_hash="hashed",
full_name="CRA PM",
clinical_department="Clinical",
role=role,
is_admin=is_admin,
status=UserStatus.ACTIVE,
)
@@ -36,7 +36,7 @@ def _make_study() -> Study:
@pytest.mark.asyncio
async def test_list_studies_returns_project_role_for_non_admin(monkeypatch):
current_user = _make_user(UserRole.CRA)
current_user = _make_user()
study = _make_study()
member = StudyMember(
id=uuid.uuid4(),
@@ -62,7 +62,7 @@ async def test_list_studies_returns_project_role_for_non_admin(monkeypatch):
@pytest.mark.asyncio
async def test_list_studies_does_not_map_system_admin_to_project_admin(monkeypatch):
current_user = _make_user(UserRole.ADMIN)
current_user = _make_user(is_admin=True)
study = _make_study()
async def fake_list_studies(_db, skip=0, limit=100):