Remove the guest system entirely: no is_guest/device_id, no guest throttles, phone login is the only way in
accounts.0008 drops the columns and refuses to run while guest rows exist. Docs describe the current state; tests that only proved guest behaviour are gone. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,7 +13,7 @@ from django.test import TestCase
|
||||
from rest_framework.test import APIClient
|
||||
|
||||
from accounts.models import User
|
||||
from accounts.testing import guest_session
|
||||
from accounts.authentication import issue_access_token
|
||||
from content.models import Choice, Grade, Lesson, Node, Question, Unit
|
||||
|
||||
|
||||
@@ -46,8 +46,8 @@ class BasicLearningFlowTests(TestCase):
|
||||
self.client.credentials(HTTP_AUTHORIZATION=f'Bearer {token}')
|
||||
|
||||
def test_a_new_user_can_go_from_signup_to_finishing_a_lesson(self):
|
||||
# ۱. حسابِ مهمانِ قدیمی (ورودِ مهمان حذف شده؛ این ردیفها هنوز هستند).
|
||||
session = guest_session('flow-device-1')
|
||||
# ۱. کاربرِ ثبتنامشده با شماره (توکنِ ورود).
|
||||
session = {'token': issue_access_token(User.objects.create(phone='09000000101', name='').id)}
|
||||
self._auth(session['token'])
|
||||
|
||||
# ۲. صفحهی «بیا باهم آشنا بشیم»: اسم + پایه.
|
||||
@@ -110,7 +110,7 @@ class BasicLearningFlowTests(TestCase):
|
||||
def test_completing_twice_with_the_same_key_does_not_double_count(self):
|
||||
from content.models import UserLessonCompletion
|
||||
|
||||
session = guest_session('flow-device-2')
|
||||
session = {'token': issue_access_token(User.objects.create(phone='09000000102', name='').id)}
|
||||
self._auth(session['token'])
|
||||
self.client.post('/api/user/grade', {'gradeId': self.grade.id}, format='json')
|
||||
self.client.post(
|
||||
@@ -144,7 +144,7 @@ class BasicLearningFlowTests(TestCase):
|
||||
بهروز میشود. بدونِ دانستنِ این، توسعهدهندهی فرانت دنبالِ باگی
|
||||
میگردد که وجود ندارد.
|
||||
"""
|
||||
session = guest_session('flow-device-4')
|
||||
session = {'token': issue_access_token(User.objects.create(phone='09000000104', name='').id)}
|
||||
self._auth(session['token'])
|
||||
self.client.post('/api/user/grade', {'gradeId': self.grade.id}, format='json')
|
||||
|
||||
@@ -162,7 +162,7 @@ class BasicLearningFlowTests(TestCase):
|
||||
self.assertGreater(self.client.get('/api/user/summary').data['xp'], 0)
|
||||
|
||||
def test_the_map_is_empty_but_healthy_before_a_grade_is_chosen(self):
|
||||
session = guest_session('flow-device-3')
|
||||
session = {'token': issue_access_token(User.objects.create(phone='09000000103', name='').id)}
|
||||
self._auth(session['token'])
|
||||
|
||||
home = self.client.get('/api/home')
|
||||
@@ -191,7 +191,7 @@ class LessonWithoutQuestionsTests(TestCase):
|
||||
)
|
||||
Choice.objects.create(question=question, value='الف', is_correct=True)
|
||||
|
||||
user = User.objects.create(device_id='empty-lesson', is_guest=True, grade_id=grade.id)
|
||||
user = User.objects.create(phone='09000000008', grade_id=grade.id)
|
||||
from accounts.authentication import issue_access_token
|
||||
self.client.credentials(HTTP_AUTHORIZATION=f'Bearer {issue_access_token(user.id)}')
|
||||
|
||||
@@ -315,7 +315,7 @@ class LessonCompletionNotificationTests(TestCase):
|
||||
self.correct = Choice.objects.create(question=question, value='الف', is_correct=True)
|
||||
self.question = question
|
||||
|
||||
self.user = User.objects.create(device_id='notif-on-complete', is_guest=True, grade_id=grade.id)
|
||||
self.user = User.objects.create(phone='09000000009', grade_id=grade.id)
|
||||
from accounts.authentication import issue_access_token
|
||||
self.client.credentials(HTTP_AUTHORIZATION=f'Bearer {issue_access_token(self.user.id)}')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user