feat: update init users

This commit is contained in:
2026-06-13 13:21:53 +08:00
parent 05ce7e987e
commit 46761906fe
11 changed files with 502 additions and 430 deletions
+6 -6
View File
@@ -272,16 +272,16 @@ class UserListDetailNegativeTest(CacheTestCase):
self.assertEqual(resp.status_code, 403, resp.content)
self.assertEqual(resp.json()['code'], 'USER_NO_LIST_PERMISSION')
def test_doctor_list_403(self):
"""N12: doctor GET /users/ → 403 USER_NO_LIST_PERMISSION"""
def test_doctor_list_returns_own_students_only(self):
"""N12(新设计): doctor=带教医生 GET /users/ → 200,仅名下学生(无学生时为空列表)"""
doctor = create_test_user(
phone='13800002002', password='Doc12345',
real_name='医生', role_type='doctor',
)
client = get_auth_client(doctor)
resp = client.get(USER_LIST_URL)
self.assertEqual(resp.status_code, 403, resp.content)
self.assertEqual(resp.json()['code'], 'USER_NO_LIST_PERMISSION')
self.assertEqual(resp.status_code, 200, resp.content)
self.assertEqual(resp.json()['count'], 0) # 无名下学生 → 空
def test_unauth_list_401(self):
"""N13: 未登录 GET /users/ → 401"""
@@ -315,7 +315,7 @@ class UserListDetailNegativeTest(CacheTestCase):
"""N16: teacher 查看非名下学生详情 → 403 USER_NO_VIEW_PERMISSION"""
teacher = create_test_user(
phone='13800002030', password='Teacher1',
real_name='刘老师', role_type='teacher',
real_name='刘老师', role_type='doctor',
)
unrelated = create_test_user(
phone='13800002031', password='Stu12345',
@@ -331,7 +331,7 @@ class UserListDetailNegativeTest(CacheTestCase):
"""N17: teacher 查看已结束关系学生详情 → 403 USER_NO_VIEW_PERMISSION"""
teacher = create_test_user(
phone='13800002040', password='Teacher1',
real_name='陈老师', role_type='teacher',
real_name='陈老师', role_type='doctor',
)
student = create_test_user(
phone='13800002041', password='Stu12345',