Update factory syntax in unit test
This commit is contained in:
parent
66dc8708b6
commit
f15afbf551
|
|
@ -1,9 +1,12 @@
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
from wagtail.rich_text import RichText
|
||||||
from assignments.models import Assignment
|
from assignments.models import Assignment
|
||||||
|
from assignments.factories import AssignmentFactory
|
||||||
|
|
||||||
from books.factories import BookFactory, ContentBlockFactory
|
from books.factories import BookFactory, ContentBlockFactory
|
||||||
from books.models.contentblock import ContentBlock
|
from books.models.contentblock import ContentBlock
|
||||||
from core.logger import get_logger
|
from core.logger import get_logger
|
||||||
|
from surveys.factories import SurveyFactory
|
||||||
from surveys.models import Survey
|
from surveys.models import Survey
|
||||||
from users.services import create_users
|
from users.services import create_users
|
||||||
|
|
||||||
|
|
@ -14,20 +17,18 @@ class DuplicateContentsTestCase(TestCase):
|
||||||
def setUp(self) -> None:
|
def setUp(self) -> None:
|
||||||
create_users()
|
create_users()
|
||||||
_, _, self.module, chapter, _ = BookFactory.create_default_structure()
|
_, _, self.module, chapter, _ = BookFactory.create_default_structure()
|
||||||
text = {"type": "text_block", "value": {"text": "Hallo"}}
|
self.assignment = AssignmentFactory(assignment="Assignment", title="Hello")
|
||||||
assignment = {
|
survey = SurveyFactory(title="Survey Title")
|
||||||
"type": "assignment",
|
rich_text = RichText("Hallo")
|
||||||
"value": {"title": "Hello", "assignment": "Assignment"},
|
|
||||||
}
|
|
||||||
survey = {"type": "survey", "value": {"title": "Survey Title", "data": "null"}}
|
|
||||||
self.content_block = ContentBlockFactory.create(
|
self.content_block = ContentBlockFactory.create(
|
||||||
parent=chapter,
|
parent=chapter,
|
||||||
module=self.module,
|
module=self.module,
|
||||||
title="Another content block",
|
title="Another content block",
|
||||||
type="task",
|
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):
|
def test_duplicate_entities(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue