def test_get_static_tab_fragment(self): self.setup_user() course = get_course_by_id(self.course.id) request = get_mock_request(self.user) tab = xmodule_tabs.CourseTabList.get_tab_by_slug(course.tabs, 'new_tab') # Test render works okay tab_content = get_static_tab_fragment(request, course, tab).content self.assertIn(self.course.id.to_deprecated_string(), tab_content) self.assertIn('static_tab', tab_content) # Test when render raises an exception with patch('courseware.views.views.get_module') as mock_module_render: mock_module_render.return_value = MagicMock( render=Mock(side_effect=Exception('Render failed!')) ) static_tab_content = get_static_tab_fragment(request, course, tab).content self.assertIn("this module is temporarily unavailable", static_tab_content)
def test_get_static_tab_fragment(self): self.setup_user() course = get_course_by_id(self.course.id) request = get_mock_request(self.user) tab = xmodule_tabs.CourseTabList.get_tab_by_slug(course.tabs, 'new_tab') # Test render works okay tab_content = get_static_tab_fragment(request, course, tab).content self.assertIn(self.course.id.to_deprecated_string(), tab_content) self.assertIn('static_tab', tab_content) # Test when render raises an exception with patch('courseware.views.views.get_module') as mock_module_render: mock_module_render.return_value = MagicMock( render=Mock(side_effect=Exception('Render failed!')) ) static_tab_content = get_static_tab_fragment(request, course, tab).content self.assertIn("this module is temporarily unavailable", static_tab_content)