'Test case scaffolding'

@patch.dict('django.conf.settings.FEATURES', {'ENTRANCE_EXAMS': True})
def setUp(self):

    super(EntranceExamTestCases, self).setUp()
    self.course = CourseFactory.create(metadata={'entrance_exam_enabled': True})
    with self.store.bulk_operations(self.course.id):
        self.chapter = ItemFactory.create(parent=self.course, display_name='Overview')
        self.welcome = ItemFactory.create(parent=self.chapter, display_name='Welcome')
        ItemFactory.create(parent=self.course, category='chapter', display_name='Week    1')
        self.chapter_subsection = ItemFactory.create(parent=self.chapter, category='sequential', display_name='Lesson    1')
        chapter_vertical = ItemFactory.create(parent=self.chapter_subsection, category='vertical', display_name='Lesson    1    Vertical    -    Unit    1')
        ItemFactory.create(parent=chapter_vertical, category='problem', display_name='Problem    -    Unit    1    Problem    1')
        ItemFactory.create(parent=chapter_vertical, category='problem', display_name='Problem    -    Unit    1    Problem    2')
        ItemFactory.create(category='instructor', parent=self.course, data='Instructor    Tab', display_name='Instructor')
        self.entrance_exam = ItemFactory.create(parent=self.course, category='chapter', display_name='Entrance    Exam    Section    -    Chapter    1', is_entrance_exam=True, in_entrance_exam=True)
        self.exam_1 = ItemFactory.create(parent=self.entrance_exam, category='sequential', display_name='Exam    Sequential    -    Subsection    1', graded=True, in_entrance_exam=True)
        subsection = ItemFactory.create(parent=self.exam_1, category='vertical', display_name='Exam    Vertical    -    Unit    1')
        problem_xml = MultipleChoiceResponseXMLFactory().build_xml(question_text='The    correct    answer    is    Choice    3', choices=[False, False, True, False], choice_names=['choice_0', 'choice_1', 'choice_2', 'choice_3'])
        self.problem_1 = ItemFactory.create(parent=subsection, category='problem', display_name='Exam    Problem    -    Problem    1', data=problem_xml)
        self.problem_2 = ItemFactory.create(parent=subsection, category='problem', display_name='Exam    Problem    -    Problem    2')
    add_entrance_exam_milestone(self.course, self.entrance_exam)
    self.course.entrance_exam_enabled = True
    self.course.entrance_exam_minimum_score_pct = 0.5
    self.course.entrance_exam_id = unicode(self.entrance_exam.scope_ids.usage_id)
    self.anonymous_user = AnonymousUserFactory()
    self.request = get_mock_request(UserFactory())
    modulestore().update_item(self.course, self.request.user.id)
    self.client.login(username=self.request.user.username, password='test')
    CourseEnrollment.enroll(self.request.user, self.course.id)
    self.expected_locked_toc = [{'active': True, 'sections': [{'url_name': u'Exam_Sequential_-_Subsection_1', 'display_name': u'Exam    Sequential    -    Subsection    1', 'graded': True, 'format': '', 'due': None, 'active': True}], 'url_name': u'Entrance_Exam_Section_-_Chapter_1', 'display_name': u'Entrance    Exam    Section    -    Chapter    1', 'display_id': u'entrance-exam-section-chapter-1'}]
    self.expected_unlocked_toc = [{'active': False, 'sections': [{'url_name': u'Welcome', 'display_name': u'Welcome', 'graded': False, 'format': '', 'due': None, 'active': False}, {'url_name': u'Lesson_1', 'display_name': u'Lesson    1', 'graded': False, 'format': '', 'due': None, 'active': False}], 'url_name': u'Overview', 'display_name': u'Overview', 'display_id': u'overview'}, {'active': False, 'sections': [], 'url_name': u'Week_1', 'display_name': u'Week    1', 'display_id': u'week-1'}, {'active': False, 'sections': [], 'url_name': u'Instructor', 'display_name': u'Instructor', 'display_id': u'instructor'}, {'active': True, 'sections': [{'url_name': u'Exam_Sequential_-_Subsection_1', 'display_name': u'Exam    Sequential    -    Subsection    1', 'graded': True, 'format': '', 'due': None, 'active': True}], 'url_name': u'Entrance_Exam_Section_-_Chapter_1', 'display_name': u'Entrance    Exam    Section    -    Chapter    1', 'display_id': u'entrance-exam-section-chapter-1'}]
