'Creates a test course.'

@classmethod
def create_test_course(cls):

    course = CourseFactory.create()
    with cls.store.bulk_operations(course.id):
        chapter = ItemFactory.create(category='chapter', parent_location=course.location)
        sequential = ItemFactory.create(category='sequential', parent_location=chapter.location)
        sequential2 = ItemFactory.create(category='sequential', parent_location=chapter.location)
        vertical = ItemFactory.create(category='vertical', parent_location=sequential.location)
        vertical2 = ItemFactory.create(category='vertical', parent_location=sequential2.location)
    course.children = [chapter]
    chapter.children = [sequential, sequential2]
    sequential.children = [vertical]
    sequential2.children = [vertical2]
    if hasattr(cls, 'user'):
        CourseEnrollment.enroll(cls.user, course.id)
    return course
