diff --git a/server/books/tests/test_duplicate_contents.py b/server/books/tests/test_duplicate_contents.py index 86e5f4ac..d5beebf4 100644 --- a/server/books/tests/test_duplicate_contents.py +++ b/server/books/tests/test_duplicate_contents.py @@ -1,9 +1,12 @@ from django.test import TestCase +from wagtail.rich_text import RichText from assignments.models import Assignment +from assignments.factories import AssignmentFactory from books.factories import BookFactory, ContentBlockFactory from books.models.contentblock import ContentBlock from core.logger import get_logger +from surveys.factories import SurveyFactory from surveys.models import Survey from users.services import create_users @@ -14,20 +17,18 @@ class DuplicateContentsTestCase(TestCase): def setUp(self) -> None: create_users() _, _, self.module, chapter, _ = BookFactory.create_default_structure() - text = {"type": "text_block", "value": {"text": "Hallo"}} - assignment = { - "type": "assignment", - "value": {"title": "Hello", "assignment": "Assignment"}, - } - survey = {"type": "survey", "value": {"title": "Survey Title", "data": "null"}} + self.assignment = AssignmentFactory(assignment="Assignment", title="Hello") + survey = SurveyFactory(title="Survey Title") + rich_text = RichText("Hallo") self.content_block = ContentBlockFactory.create( parent=chapter, module=self.module, title="Another content block", type="task", - contents=[text, assignment, survey], + contents__0__text_block__text=rich_text, + contents__1__assignment__assignment_id=self.assignment, + contents__2__survey__survey_id=survey, ) - self.assignment = Assignment.objects.first() def test_duplicate_entities(self): self.assertEqual(