Add test to replicate order bug
This commit is contained in:
parent
c22238e5a6
commit
ea1816e3cc
|
|
@ -1,18 +1,8 @@
|
||||||
from django.test import RequestFactory
|
from books.factories import ModuleFactory, ChapterFactory
|
||||||
from graphene.test import Client
|
|
||||||
from graphql_relay import to_global_id, from_global_id
|
|
||||||
|
|
||||||
from api.schema import schema
|
|
||||||
from api.utils import get_object
|
|
||||||
from books.factories import ModuleFactory, ChapterFactory, ContentBlockFactory
|
|
||||||
from books.management.commands.migrate_objective_snapshots import migrate_snapshots
|
|
||||||
from books.management.commands.migrate_objectives_to_content import migrate_objectives_to_content
|
from books.management.commands.migrate_objectives_to_content import migrate_objectives_to_content
|
||||||
from books.models import Snapshot, ChapterSnapshot
|
from books.tests.queries import MODULE_QUERY
|
||||||
from books.tests.queries import MODULE_QUERY, SNAPSHOT_MODULE_QUERY, CREATE_SNAPSHOT_MUTATION, APPLY_SNAPSHOT_MUTATION, \
|
|
||||||
MODULE_SNAPSHOTS_QUERY, SHARE_SNAPSHOT_MUTATION, UPDATE_SNAPSHOT_MUTATION, DELETE_SNAPSHOT_MUTATION
|
|
||||||
from core.tests.base_test import SkillboxTestCase
|
from core.tests.base_test import SkillboxTestCase
|
||||||
from objectives.factories import ObjectiveGroupFactory, ObjectiveFactory
|
from objectives.factories import ObjectiveGroupFactory, ObjectiveFactory
|
||||||
from users.factories import SchoolClassFactory
|
|
||||||
from users.models import User, SchoolClass
|
from users.models import User, SchoolClass
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -42,6 +32,7 @@ class TestObjectivesMigration(SkillboxTestCase):
|
||||||
|
|
||||||
objective_group = ObjectiveGroupFactory(module=self.module, title='Gesellschaft')
|
objective_group = ObjectiveGroupFactory(module=self.module, title='Gesellschaft')
|
||||||
second_objective_group = ObjectiveGroupFactory(module=self.module, title='Sprache & Kommunikation')
|
second_objective_group = ObjectiveGroupFactory(module=self.module, title='Sprache & Kommunikation')
|
||||||
|
third_objective_group = ObjectiveGroupFactory(module=self.module, title='Übergeordnete Lernziele')
|
||||||
|
|
||||||
self.visible_objective = ObjectiveFactory(text='visible-objective', group=objective_group)
|
self.visible_objective = ObjectiveFactory(text='visible-objective', group=objective_group)
|
||||||
self.hidden_objective = ObjectiveFactory(text='hidden-objective', group=objective_group)
|
self.hidden_objective = ObjectiveFactory(text='hidden-objective', group=objective_group)
|
||||||
|
|
@ -109,3 +100,21 @@ class TestObjectivesMigration(SkillboxTestCase):
|
||||||
self.assertEqual(hidden_custom['hiddenFor'], [])
|
self.assertEqual(hidden_custom['hiddenFor'], [])
|
||||||
self.assertEqual(hidden_custom['visibleFor'], [])
|
self.assertEqual(hidden_custom['visibleFor'], [])
|
||||||
self.assertEqual(hidden_custom['contents'][0]['value']['text'], '<ul><li>objective1</li></ul>')
|
self.assertEqual(hidden_custom['contents'][0]['value']['text'], '<ul><li>objective1</li></ul>')
|
||||||
|
|
||||||
|
def test_objectives_order(self):
|
||||||
|
"""The correct oder of the objectives is:
|
||||||
|
- Sprache & Kommunikation
|
||||||
|
- Gesellschaft
|
||||||
|
- Übergeordnete Lernziele
|
||||||
|
"""
|
||||||
|
|
||||||
|
result = self.client.execute(MODULE_QUERY, variables={
|
||||||
|
'slug': self.module.slug
|
||||||
|
})
|
||||||
|
module = result.data['module']
|
||||||
|
chapter1 = module['chapters'][0]
|
||||||
|
titles = [content['title'] for content in chapter1['contentBlocks']]
|
||||||
|
self.assertEqual(titles, ['Sprache & Kommunikation', 'Gesellschaft','Gesellschaft','Übergeordnete Lernziele'])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue