feat: cms softdelet bug fix

This commit is contained in:
2026-06-11 13:57:46 +08:00
parent 32915bc6b4
commit f2dcf3d490
6 changed files with 60 additions and 8 deletions
+12
View File
@@ -127,6 +127,18 @@ class CmsUserCrudTest(CacheTestCase):
obj = User.all_objects.get(id=u.id)
self.assertTrue(obj.is_deleted) # 实际未物删
def test_recreate_soft_deleted_phone_returns_400(self):
"""软删后用相同手机号重建:返回 400 CMS_USER_PHONE_EXISTS(不产生重复行)。"""
u = create_test_user(phone='13922200061', role_type='student', institution=self.inst)
self.client.delete(u_detail(u.id))
self.assertFalse(User.objects.filter(phone='13922200061').exists())
resp = self.client.post(CMS_USER_URL, {
'phone': '13922200061', 'real_name': '重建', 'role_type': 'student',
'institution': self.inst.id})
self.assertEqual(resp.status_code, 400, resp.content)
self.assertEqual(resp.json()['code'], 'CMS_USER_PHONE_EXISTS')
self.assertEqual(User.all_objects.filter(phone='13922200061').count(), 1)
def test_reset_password(self):
u = create_test_user(phone='13922200070', password='OldPass1', role_type='student')
resp = self.client.post(f'/api/cms/users/{u.id}/reset-password/', {})