Exemple #1
0
    def test_iterate_displayable(self):
        # enable all tab types
        self.settings.FEATURES['ENABLE_TEXTBOOK'] = True
        self.settings.FEATURES['ENABLE_DISCUSSION_SERVICE'] = True
        self.settings.FEATURES['ENABLE_STUDENT_NOTES'] = True
        self.settings.FEATURES['ENABLE_EDXNOTES'] = True
        self.course.hide_progress_tab = False

        # create 1 book per textbook type
        self.set_up_books(1)

        # initialize the course tabs to a list of all valid tabs
        self.course.tabs = self.all_valid_tab_list

        # enumerate the tabs using the CMS call
        for i, tab in enumerate(
                tabs.CourseTabList.iterate_displayable_cms(
                    self.course,
                    self.settings,
                )):
            self.assertEquals(tab.type, self.course.tabs[i].type)

        # enumerate the tabs and verify textbooks and the instructor tab
        for i, tab in enumerate(
                tabs.CourseTabList.iterate_displayable(
                    self.course,
                    self.settings,
                )):
            if getattr(tab, 'is_collection_item', False):
                # a collection item was found as a result of a collection tab
                self.assertTrue(
                    getattr(self.course.tabs[i], 'is_collection', False))
            elif i == len(self.course.tabs):
                # the last tab must be the Instructor tab
                self.assertEquals(tab.type, tabs.InstructorTab.type)
            else:
                # all other tabs must match the expected type
                self.assertEquals(tab.type, self.course.tabs[i].type)

        # test including non-empty collections
        self.assertIn(
            tabs.HtmlTextbookTabs(),
            list(
                tabs.CourseTabList.iterate_displayable_cms(
                    self.course, self.settings)),
        )

        # test not including empty collections
        self.course.html_textbooks = []
        self.assertNotIn(
            tabs.HtmlTextbookTabs(),
            list(
                tabs.CourseTabList.iterate_displayable_cms(
                    self.course, self.settings)),
        )
Exemple #2
0
 def setUp(self):
     self.course = CourseFactory.create()
     self.set_up_books(2)
     self.course.tabs = [
         tabs.CoursewareTab(),
         tabs.CourseInfoTab(),
         tabs.TextbookTabs(),
         tabs.PDFTextbookTabs(),
         tabs.HtmlTextbookTabs(),
     ]
     self.setup_user()
     self.enroll(self.course)
     self.num_textbook_tabs = sum(1 for tab in self.course.tabs
                                  if isinstance(tab, tabs.TextbookTabsBase))
     self.num_textbooks = self.num_textbook_tabs * len(self.books)
Exemple #3
0
    def setUp(self):
        super(TextbooksTestCase, self).setUp()

        self.set_up_books(2)

        self.dict_tab = MagicMock()
        self.course.tabs = [
            tabs.CoursewareTab(),
            tabs.CourseInfoTab(),
            tabs.TextbookTabs(),
            tabs.PDFTextbookTabs(),
            tabs.HtmlTextbookTabs(),
        ]
        self.num_textbook_tabs = sum(1 for tab in self.course.tabs
                                     if isinstance(tab, tabs.TextbookTabsBase))
        self.num_textbooks = self.num_textbook_tabs * len(self.books)