def test_course_structure_to_sections(self):
        factory = CourseStructureFactory()
        structure = factory.structure

        actual = CourseStructure.course_structure_to_sections(structure, False)
        self.assertListEqual(
            actual, self._prepare_structure(structure, factory.sections,
                                            False))
    def test_course_structure_to_assignments(self):
        factory = CourseStructureFactory()
        structure = factory.structure

        actual = CourseStructure.course_structure_to_assignments(structure,
                                                                 graded=True)
        expected = self._prepare_structure(structure, factory.assignments)
        self.assertListEqual(actual, expected)

        # Test for assignment type filtering
        assignment_type = factory.grading_policy[0]['assignment_type']
        actual = CourseStructure.course_structure_to_assignments(
            structure, graded=True, assignment_type=assignment_type)
        assignments = [
            assignment for assignment in factory.assignments
            if assignment['format'] == assignment_type
        ]
        expected = self._prepare_structure(structure, assignments)
        self.assertListEqual(actual, expected)