feat(users): add transactional employee deletion and token revocation
All checks were successful
State Corp Backend CI/CD / Quality gate (push) Successful in 2m42s
State Corp Backend CI/CD / Build linux/amd64 images once (push) Successful in 5m29s
State Corp Backend CI/CD / Refresh and release internal main (push) Has been skipped
State Corp Backend CI/CD / Release customer main (push) Has been skipped
State Corp Backend CI/CD / Release dev (push) Successful in 36s

This commit is contained in:
Aleksandr Meshchryakov
2026-09-13 22:55:31 +02:00
parent ef087d5559
commit e99616ed6d
9 changed files with 971 additions and 69 deletions

View File

@@ -109,7 +109,8 @@ class UserServiceTest(TestCase):
def test_delete_user_success(self):
"""Test successful user deletion"""
user_id = self.user.id
UserService.delete_user(user_id)
admin = UserFactory.create_superuser()
UserService.delete_user(user_id, actor_id=admin.pk)
# Verify user is deleted
with self.assertRaises(NotFoundError):
@@ -118,8 +119,9 @@ class UserServiceTest(TestCase):
def test_delete_user_not_found(self):
"""Test deleting non-existing user raises NotFoundError"""
nonexistent_id = fake.pyint(min_value=900000, max_value=999999)
admin = UserFactory.create_superuser()
with self.assertRaises(NotFoundError):
UserService.delete_user(nonexistent_id)
UserService.delete_user(nonexistent_id, actor_id=admin.pk)
def test_get_tokens_for_user(self):
"""Test JWT token generation"""