NodeProgress receivers skip raw saves (loaddata duplicated rows on the Postgres move)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
18
content/tests_loaddata_raw.py
Normal file
18
content/tests_loaddata_raw.py
Normal file
@@ -0,0 +1,18 @@
|
||||
"""loaddata (انتقال به Postgres) نباید از روی سیگنال NodeProgress بسازد: خودِ ردیف در فایل است."""
|
||||
from django.db.models.signals import post_save
|
||||
from django.test import TestCase
|
||||
|
||||
from content.models import Choice, Grade, Lesson, Node, NodeProgress, Question, Unit, UserAnswer
|
||||
|
||||
|
||||
class RawSaveTests(TestCase):
|
||||
def test_raw_user_answer_save_creates_no_node_progress(self):
|
||||
grade = Grade.objects.create(title='g', number=99)
|
||||
unit = Unit.objects.create(grade=grade, title='u', order=1)
|
||||
node = Node.objects.create(unit=unit, title='n', order=1)
|
||||
lesson = Lesson.objects.create(node=node, title='l')
|
||||
q = Question.objects.create(lesson=lesson, type='multiple_choice', prompt='p')
|
||||
c = Choice.objects.create(question=q, value='a', is_correct=True)
|
||||
answer = UserAnswer(user_id=1, question=q, choice=c, correct=True)
|
||||
post_save.send(UserAnswer, instance=answer, created=True, raw=True)
|
||||
self.assertEqual(NodeProgress.objects.count(), 0)
|
||||
Reference in New Issue
Block a user