def test_advanced_components_without_display_name(self): """ Test that advanced components without display names display their category instead. """ self.course.advanced_modules.append('graphical_slider_tool') self.templates = get_component_templates(self.course) template = self.get_templates_of_type('advanced')[0] self.assertEqual(template.get('display_name'), 'graphical_slider_tool')
def test_get_component_templates(self): """ Verify that templates for adding discussion and advanced components to content libraries are not provided. """ lib = LibraryFactory.create() lib.advanced_modules = ['lti'] lib.save() templates = [template['type'] for template in get_component_templates(lib, library=True)] self.assertIn('problem', templates) self.assertNotIn('discussion', templates) self.assertNotIn('advanced', templates)
def test_advanced_components(self): """ Test the handling of advanced component templates. """ self.course.advanced_modules.append('word_cloud') self.templates = get_component_templates(self.course) advanced_templates = self.get_templates_of_type('advanced') self.assertEqual(len(advanced_templates), 1) world_cloud_template = advanced_templates[0] self.assertEqual(world_cloud_template.get('category'), 'word_cloud') self.assertEqual(world_cloud_template.get('display_name'), u'Word cloud') self.assertIsNone(world_cloud_template.get('boilerplate_name', None)) # Verify that non-advanced components are not added twice self.course.advanced_modules.append('video') self.course.advanced_modules.append('openassessment') self.templates = get_component_templates(self.course) advanced_templates = self.get_templates_of_type('advanced') self.assertEqual(len(advanced_templates), 1) only_template = advanced_templates[0] self.assertNotEqual(only_template.get('category'), 'video') self.assertNotEqual(only_template.get('category'), 'openassessment')
def test_advanced_problem_types(self): """ Verify that advanced problem types are not provided in problem component for libraries. """ lib = LibraryFactory.create() lib.save() problem_type_templates = next( (component['templates'] for component in get_component_templates(lib, library=True) if component['type'] == 'problem'), [] ) # Each problem template has a category which shows whether problem is a 'problem' # or which of the advanced problem type (e.g drag-and-drop-v2). problem_type_categories = [problem_template['category'] for problem_template in problem_type_templates] for advance_problem_type in settings.ADVANCED_PROBLEM_TYPES: self.assertNotIn(advance_problem_type['component'], problem_type_categories)
def setUp(self): super(TestComponentTemplates, self).setUp() self.templates = get_component_templates(self.course)