delete_users --real-phones: every phone user except the demo logins

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-02 02:41:16 +03:30
parent 39247f6d53
commit e9d676ce68
2 changed files with 21 additions and 1 deletions

View File

@@ -2,7 +2,7 @@
from io import StringIO
from django.core.management import CommandError, call_command
from django.test import TestCase
from django.test import TestCase, override_settings
from accounts.models import OTPCode, Profile, User
from ai_tutor.models import Conversation, Message
@@ -49,3 +49,11 @@ class DeleteUsersTests(TestCase):
self.assertTrue(User.objects.filter(pk=self.doomed.pk).exists())
self.run_command('--ids', str(self.doomed.pk), '--yes', '--include-paid')
self.assertFalse(Order.objects.filter(user_id=self.doomed.pk).exists())
@override_settings(TEST_LOGIN_PHONES={'09121110002': '1234'})
def test_real_phones_keeps_demo_numbers_and_guests(self):
guest = User.objects.create(device_id='guest-x', is_guest=True)
self.run_command('--real-phones', '--yes')
self.assertFalse(User.objects.filter(pk=self.doomed.pk).exists())
self.assertTrue(User.objects.filter(pk=self.kept.pk).exists())
self.assertTrue(User.objects.filter(pk=guest.pk).exists())