Ejemplo n.º 1
0
    def test_empty_course(self):
        """
        Test that the computed settings data is empty when the course is empty.
        """
        empty_course = CourseFactory.create(org="edx", number="999", display_name="test_course")

        computed_settings_data = BulkSettingsUtil.get_bulksettings_metadata(empty_course)
        self.assertEqual(len(computed_settings_data), 0, msg="empty course should contain no settings")
Ejemplo n.º 2
0
 def test_empty_problem(self):
     """
     Test with no problems. If no unit holds any problems, the list should be empty.
     """
     empty_problem_course = CourseFactory.create(org="edx", number="999", display_name="no_problem_course")
     self.do_recursive_population(empty_problem_course, ["chapter", "sequential", "vertical"])
     computed_settings_data = BulkSettingsUtil.get_bulksettings_metadata(empty_problem_course)
     self.assertEqual(len(computed_settings_data), 0, msg="course with no problem should yield no bulksettings")
Ejemplo n.º 3
0
    def test_bulksettings_data_correctness(self):
        """
        Test that the populated course settings correctly match the result
        from _get_bulksettings_metadata.

        _get_bulksettings_metatdata is from contentstore.views.utilities.bulksettings

        Since the test populated course only contains problems, assume that indices
        match between computed settings & block.children

        Populate self.course with 2 chapters, 4 sections, 8 verticals, 16 problems
        and for each node, put in random settings
        """
        self.populate_course_with_seed_data()
        course_module = self.store.get_items(self.course.id,
                                             category='course')[0]
        computed_settings_data = BulkSettingsUtil.get_bulksettings_metadata(
            course_module)

        num_sections = len(computed_settings_data)
        sections = course_module.get_children()
        ''' Dive into the course hierarchy and check correct values.'''
        ''' Section Layer'''
        for index in range(num_sections):
            section = sections[index]
            computed_section_settings = computed_settings_data[index]
            self.assertTrue(
                self.do_values_match(self.SECTION_SETTING_TYPES, section,
                                     computed_section_settings))

            num_subsections = len(section.get_children())
            ''' Subsection Layer '''
            for index in range(num_subsections):
                subsection = section.get_children()[index]
                computed_subsection_settings = computed_section_settings[
                    'children'][index]

                self.assertTrue(
                    self.do_values_match(self.SUBSECTION_SETTING_TYPES,
                                         subsection,
                                         computed_subsection_settings))

                num_units = len(subsection.get_children())
                ''' Unit Layer '''
                for index in range(num_units):
                    unit = subsection.get_children()[index]
                    num_components = len(unit.get_children())
                    computed_unit_settings = computed_subsection_settings[
                        'children'][index]
                    ''' Component Layer (Problems)'''
                    for index in range(num_components):
                        component = unit.get_children()[index]
                        computed_component_settings = computed_unit_settings[
                            'children'][index]
                        self.assertTrue(
                            self.do_values_match(self.PROBLEM_SETTING_TYPES,
                                                 component,
                                                 computed_component_settings))
Ejemplo n.º 4
0
    def test_bulksettings_data_correctness(self):
        """
        Test that the populated course settings correctly match the result
        from _get_bulksettings_metadata.

        _get_bulksettings_metatdata is from contentstore.views.utilities.bulksettings

        Since the test populated course only contains problems, assume that indices
        match between computed settings & block.children

        Populate self.course with 2 chapters, 4 sections, 8 verticals, 16 problems
        and for each node, put in random settings
        """
        self.populate_course_with_seed_data()
        course_module = self.store.get_items(self.course.id, category="course")[0]
        computed_settings_data = BulkSettingsUtil.get_bulksettings_metadata(course_module)

        num_sections = len(computed_settings_data)
        sections = course_module.get_children()

        """ Dive into the course hierarchy and check correct values."""

        """ Section Layer"""
        for index in range(num_sections):
            section = sections[index]
            computed_section_settings = computed_settings_data[index]
            self.assertTrue(self.do_values_match(self.SECTION_SETTING_TYPES, section, computed_section_settings))

            num_subsections = len(section.get_children())

            """ Subsection Layer """
            for index in range(num_subsections):
                subsection = section.get_children()[index]
                computed_subsection_settings = computed_section_settings["children"][index]

                self.assertTrue(
                    self.do_values_match(self.SUBSECTION_SETTING_TYPES, subsection, computed_subsection_settings)
                )

                num_units = len(subsection.get_children())

                """ Unit Layer """
                for index in range(num_units):
                    unit = subsection.get_children()[index]
                    num_components = len(unit.get_children())
                    computed_unit_settings = computed_subsection_settings["children"][index]

                    """ Component Layer (Problems)"""
                    for index in range(num_components):
                        component = unit.get_children()[index]
                        computed_component_settings = computed_unit_settings["children"][index]
                        self.assertTrue(
                            self.do_values_match(self.PROBLEM_SETTING_TYPES, component, computed_component_settings)
                        )
Ejemplo n.º 5
0
    def test_empty_course(self):
        """
        Test that the computed settings data is empty when the course is empty.
        """
        empty_course = CourseFactory.create(
            org='edx',
            number='999',
            display_name='test_course',
        )

        computed_settings_data = BulkSettingsUtil.get_bulksettings_metadata(
            empty_course)
        self.assertEqual(len(computed_settings_data),
                         0,
                         msg="empty course should contain no settings")
Ejemplo n.º 6
0
 def test_empty_problem(self):
     """
     Test with no problems. If no unit holds any problems, the list should be empty.
     """
     empty_problem_course = CourseFactory.create(
         org='edx',
         number='999',
         display_name='no_problem_course',
     )
     self.do_recursive_population(empty_problem_course,
                                  ['chapter', 'sequential', 'vertical'])
     computed_settings_data = BulkSettingsUtil.get_bulksettings_metadata(
         empty_problem_course)
     self.assertEqual(
         len(computed_settings_data),
         0,
         msg='course with no problem should yield no bulksettings',
     )