""" Test for split test XModule """ from __future__ import absolute_import import six from django.urls import reverse from mock import MagicMock from six import text_type from lms.djangoapps.courseware.model_data import FieldDataCache from lms.djangoapps.courseware.module_render import get_module_for_descriptor from openedx.core.djangoapps.user_api.tests.factories import UserCourseTagFactory from student.tests.factories import CourseEnrollmentFactory, UserFactory from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory from xmodule.partitions.partitions import Group, UserPartition class SplitTestBase(SharedModuleStoreTestCase): """ Sets up a basic course and user for split test testing. Also provides tests of rendered HTML for two user_tag conditions, 0 and 1. """ __test__ = False COURSE_NUMBER = 'split-test-base' ICON_CLASSES = None TOOLTIPS = None VISIBLE_CONTENT = None @classmethod def setUpClass(cls): super(SplitTestBase, cls).setUpClass() cls.partition = UserPartition( 0, 'first_partition', 'First Partition', [ Group(0, 'alpha'), Group(1, 'beta') ] ) cls.course = CourseFactory.create( number=cls.COURSE_NUMBER, user_partitions=[cls.partition] ) cls.chapter = ItemFactory.create( parent_location=cls.course.location, category="chapter", display_name="test chapter", ) cls.sequential = ItemFactory.create( parent_location=cls.chapter.location, category="sequential", display_name="Split Test Tests", ) def setUp(self): super(SplitTestBase, self).setUp() self.student = UserFactory.create() CourseEnrollmentFactory.create(user=self.student, course_id=self.course.id) self.client.login(username=self.student.username, password='test') self.included_usage_keys = None self.excluded_usage_keys = None def _video(self, parent, group): """ Returns a video component with parent ``parent`` that is intended to be displayed to group ``group``. """ return ItemFactory.create( parent_location=parent.location, category="video", display_name=u"Group {} Sees This Video".format(group), ) def _problem(self, parent, group): """ Returns a problem component with parent ``parent`` that is intended to be displayed to group ``group``. """ return ItemFactory.create( parent_location=parent.location, category="problem", display_name=u"Group {} Sees This Problem".format(group), data="