def test_validate_tabs(self): tab_list = xmodule_tabs.CourseTabList() for invalid_tab_list in self.invalid_tabs: with self.assertRaises(xmodule_tabs.InvalidTabsException): tab_list.from_json(invalid_tab_list) for valid_tab_list in self.valid_tabs: from_json_result = tab_list.from_json(valid_tab_list) self.assertEquals(len(from_json_result), len(valid_tab_list))
def test_validate_tabs(self): tab_list = xmodule_tabs.CourseTabList() for invalid_tab_list in self.invalid_tabs: with pytest.raises(xmodule_tabs.InvalidTabsException): tab_list.from_json(invalid_tab_list) for valid_tab_list in self.valid_tabs: from_json_result = tab_list.from_json(valid_tab_list) assert len(from_json_result) == len(valid_tab_list)
def test_invalid_tab_type(self): """ Verifies that having an unrecognized tab type does not cause the tabs to be undisplayable. """ tab_list = xmodule_tabs.CourseTabList() assert len(tab_list.from_json([{'type': CoursewareTab.type}, {'type': CourseInfoTab.type, 'name': 'fake_name'}, {'type': 'no_such_type'}])) == 2
def setUp(self): super(TabListTestCase, self).setUp() # invalid tabs self.invalid_tabs = [ # less than 2 tabs [{'type': CoursewareTab.type}], # missing course_info [{'type': CoursewareTab.type}, {'type': 'discussion', 'name': 'fake_name'}], [{'type': 'unknown_type'}], # incorrect order [{'type': 'discussion', 'name': 'fake_name'}, {'type': CourseInfoTab.type, 'name': 'fake_name'}, {'type': CoursewareTab.type}], ] # valid tabs self.valid_tabs = [ # any empty list is valid because a default list of tabs will be # generated to replace the empty list. [], # all valid tabs [ {'type': CoursewareTab.type}, {'type': CourseInfoTab.type, 'name': 'fake_name'}, {'type': 'discussion', 'name': 'fake_name'}, {'type': ExternalLinkCourseTab.type, 'name': 'fake_name', 'link': 'fake_link'}, {'type': ExternalLinkCourseTab.type, 'name': 'fake_name', 'link': 'fake_link'}, {'type': 'textbooks'}, {'type': 'pdf_textbooks'}, {'type': 'html_textbooks'}, {'type': ProgressTab.type, 'name': 'fake_name'}, {'type': xmodule_tabs.StaticTab.type, 'name': 'fake_name', 'url_slug': 'schlug'}, {'type': 'syllabus'}, ], # with external discussion [ {'type': CoursewareTab.type}, {'type': CourseInfoTab.type, 'name': 'fake_name'}, {'type': ExternalDiscussionCourseTab.type, 'name': 'fake_name', 'link': 'fake_link'} ], ] self.all_valid_tab_list = xmodule_tabs.CourseTabList().from_json(self.valid_tabs[1])
def setUp(self): super(TabListTestCase, self).setUp() # invalid tabs self.invalid_tabs = [ # less than 2 tabs [{ 'type': tabs.CoursewareTab.type }], # missing course_info [{ 'type': tabs.CoursewareTab.type }, { 'type': tabs.DiscussionTab.type, 'name': 'fake_name' }], # incorrect order [{ 'type': tabs.CourseInfoTab.type, 'name': 'fake_name' }, { 'type': tabs.CoursewareTab.type }], # invalid type [{ 'type': tabs.CoursewareTab.type }, { 'type': tabs.CourseInfoTab.type, 'name': 'fake_name' }, { 'type': 'fake_type' }], ] # tab types that should appear only once unique_tab_types = [ tabs.CourseInfoTab.type, tabs.CoursewareTab.type, tabs.NotesTab.type, tabs.TextbookTabs.type, tabs.PDFTextbookTabs.type, tabs.HtmlTextbookTabs.type, ] for unique_tab_type in unique_tab_types: self.invalid_tabs.append([ { 'type': tabs.CoursewareTab.type }, { 'type': tabs.CourseInfoTab.type, 'name': 'fake_name' }, # add the unique tab multiple times { 'type': unique_tab_type }, { 'type': unique_tab_type }, ]) # valid tabs self.valid_tabs = [ # empty list [], # all valid tabs [ { 'type': tabs.CoursewareTab.type }, { 'type': tabs.CourseInfoTab.type, 'name': 'fake_name' }, { 'type': tabs.WikiTab.type, 'name': 'fake_name' }, { 'type': tabs.DiscussionTab.type, 'name': 'fake_name' }, { 'type': tabs.ExternalLinkTab.type, 'name': 'fake_name', 'link': 'fake_link' }, { 'type': tabs.TextbookTabs.type }, { 'type': tabs.PDFTextbookTabs.type }, { 'type': tabs.HtmlTextbookTabs.type }, { 'type': tabs.ProgressTab.type, 'name': 'fake_name' }, { 'type': tabs.StaticTab.type, 'name': 'fake_name', 'url_slug': 'schlug' }, { 'type': tabs.PeerGradingTab.type }, { 'type': tabs.StaffGradingTab.type }, { 'type': tabs.OpenEndedGradingTab.type }, { 'type': tabs.NotesTab.type, 'name': 'fake_name' }, { 'type': tabs.SyllabusTab.type }, ], # with external discussion [{ 'type': tabs.CoursewareTab.type }, { 'type': tabs.CourseInfoTab.type, 'name': 'fake_name' }, { 'type': tabs.ExternalDiscussionTab.type, 'name': 'fake_name', 'link': 'fake_link' }], ] self.all_valid_tab_list = tabs.CourseTabList().from_json( self.valid_tabs[1])
def setUp(self): super().setUp() # invalid tabs self.invalid_tabs = [ # less than 2 tabs [{ 'type': CoursewareTab.type }], # missing course_info [{ 'type': CoursewareTab.type }, { 'type': 'discussion', 'name': 'fake_name' }], [{ 'type': 'unknown_type' }], # incorrect order [{ 'type': 'discussion', 'name': 'fake_name' }, { 'type': CourseInfoTab.type, 'name': 'fake_name' }, { 'type': CoursewareTab.type }], ] # tab types that should appear only once unique_tab_types = [ CoursewareTab.type, CourseInfoTab.type, 'textbooks', 'pdf_textbooks', 'html_textbooks', ] for unique_tab_type in unique_tab_types: self.invalid_tabs.append([ { 'type': CoursewareTab.type }, { 'type': CourseInfoTab.type, 'name': 'fake_name' }, # add the unique tab multiple times { 'type': unique_tab_type }, { 'type': unique_tab_type }, ]) # valid tabs self.valid_tabs = [ # any empty list is valid because a default list of tabs will be # generated to replace the empty list. [], # all valid tabs [ { 'type': CoursewareTab.type }, { 'type': CourseInfoTab.type, 'name': 'fake_name' }, { 'type': DatesTab.type }, # Add this even though we filter it out, for testing purposes { 'type': 'discussion', 'name': 'fake_name' }, { 'type': ExternalLinkCourseTab.type, 'name': 'fake_name', 'link': 'fake_link' }, { 'type': ExternalLinkCourseTab.type, 'name': 'fake_name', 'link': 'fake_link' }, { 'type': 'textbooks' }, { 'type': 'pdf_textbooks' }, { 'type': 'html_textbooks' }, { 'type': ProgressTab.type, 'name': 'fake_name' }, { 'type': xmodule_tabs.StaticTab.type, 'name': 'fake_name', 'url_slug': 'schlug' }, { 'type': 'syllabus' }, ], # with external discussion [{ 'type': CoursewareTab.type }, { 'type': CourseInfoTab.type, 'name': 'fake_name' }, { 'type': ExternalDiscussionCourseTab.type, 'name': 'fake_name', 'link': 'fake_link' }], ] self.all_valid_tab_list = xmodule_tabs.CourseTabList().from_json( self.valid_tabs[1])