예제 #1
0
 def test_get_non_existant_course(self):
     """
     Test non-existant course returns empty list.
     """
     self.assertEqual(get_course_chapter_ids(None), [])
     # build a fake key
     fake_course_key = CourseKey.from_string('course-v1:FakeOrg+CN1+CR-FALLNEVER1')
     self.assertEqual(get_course_chapter_ids(fake_course_key), [])
예제 #2
0
 def test_get_non_existant_course(self):
     """
     Test non-existant course returns empty list.
     """
     self.assertEqual(get_course_chapter_ids(None), [])
     # build a fake key
     fake_course_key = CourseKey.from_string('course-v1:FakeOrg+CN1+CR-FALLNEVER1')
     self.assertEqual(get_course_chapter_ids(fake_course_key), [])
예제 #3
0
 def test_get_chapters(self):
     """
     Test get_course_chapter_ids returns expected result.
     """
     course = CourseFactory()
     ItemFactory(parent=course, category='chapter')
     ItemFactory(parent=course, category='chapter')
     course_chapter_ids = get_course_chapter_ids(course.location.course_key)
     self.assertEqual(len(course_chapter_ids), 2)
     self.assertEqual(course_chapter_ids,
                      [six.text_type(child) for child in course.children])
예제 #4
0
def valid_course_modules(course_module_list, master_course_key):
    """
    Function to validate that each element in the course_module_list belongs
    to the master course structure.
    Args:
        course_module_list (list): A list of strings representing Block Usage Keys
        master_course_key (CourseKey): An object representing the master course key id

    Returns:
        bool: whether or not all the course module strings belong to the master course
    """
    course_chapters = courses.get_course_chapter_ids(master_course_key)
    return set(course_module_list).intersection(set(course_chapters)) == set(course_module_list)
def valid_course_modules(course_module_list, master_course_key):
    """
    Function to validate that each element in the course_module_list belongs
    to the master course structure.
    Args:
        course_module_list (list): A list of strings representing Block Usage Keys
        master_course_key (CourseKey): An object representing the master course key id

    Returns:
        bool: whether or not all the course module strings belong to the master course
    """
    course_chapters = courses.get_course_chapter_ids(master_course_key)
    return set(course_module_list).intersection(set(course_chapters)) == set(course_module_list)
예제 #6
0
 def test_get_chapters(self):
     """
     Test get_course_chapter_ids returns expected result.
     """
     course = CourseFactory()
     ItemFactory(parent=course, category='chapter')
     ItemFactory(parent=course, category='chapter')
     course_chapter_ids = get_course_chapter_ids(course.location.course_key)
     self.assertEqual(len(course_chapter_ids), 2)
     self.assertEqual(
         course_chapter_ids,
         [unicode(child) for child in course.children]
     )