'Create the course that\'ll be published below. The course has a binary structure, meaning:
The course has two chapters (chapter_0 & chapter_1),
each of which has two sequentials (sequential_0/1 & sequential_2/3),
each of which has two verticals (vertical_0/1 - vertical_6/7),
each of which has two units (unit_0/1 - unit_14/15).'

def _create_course(self, store):

    def _make_block_id(block_type, num):
        '\n                                                Given    a    block_type/num,    return    a    block    id.\n                                                '
        return '{}{:02d}'.format(block_type, num)
    def _make_course_db_entry(parent_type, parent_id, block_id, idx, child_block_type, child_block_id_base):
        '\n                                                Make    a    single    entry    for    the    course    DB.\n                                                '
        return {'parent_type': parent_type, 'parent_id': parent_id, 'index_in_children_list': (idx % 2), 'filename': block_id, 'child_ids': ((child_block_type, _make_block_id(child_block_id_base, (idx * 2))), (child_block_type, _make_block_id(child_block_id_base, ((idx * 2) + 1))))}
    def _add_course_db_entry(parent_type, parent_id, block_id, block_type, idx, child_type, child_base):
        '\n                                                Add    a    single    entry    for    the    course    DB    referenced    by    the    tests    below.\n                                                '
        self.course_db.update({(block_type, block_id): _make_course_db_entry(parent_type, parent_id, block_id, idx, child_type, child_base)})
    def _create_binary_structure_items(parent_type, block_type, num_items, child_block_type):
        '\n                                                Add    a    level    of    the    binary    course    structure    by    creating    the    items    as    children    of    the    proper    parents.\n                                                '
        parent_id = 'course'
        for idx in xrange(num_items):
            if (parent_type != 'course'):
                parent_id = _make_block_id(parent_type, (idx / 2))
            parent_item = getattr(self, parent_id)
            block_id = _make_block_id(block_type, idx)
            setattr(self, block_id, ItemFactory.create(parent_location=parent_item.location, category=block_type, modulestore=store, publish_item=False, location=self.course.id.make_usage_key(block_type, block_id)))
            _add_course_db_entry(parent_type, parent_id, block_id, block_type, idx, child_block_type, child_block_type)
    with store.branch_setting(ModuleStoreEnum.Branch.draft_preferred):
        self.course = CourseFactory.create(org='test_org', number='999', run='test_run', display_name='My    Test    Course', modulestore=store)
        with store.bulk_operations(self.course.id):
            _create_binary_structure_items('course', 'chapter', 2, 'sequential')
            _create_binary_structure_items('chapter', 'sequential', 4, 'vertical')
            _create_binary_structure_items('sequential', 'vertical', 8, 'html')
            _create_binary_structure_items('vertical', 'html', 16, '')
    block_type = 'vertical'
    for idx in xrange(8):
        block_id = _make_block_id(block_type, idx)
        self.all_verticals.append((block_type, block_id))
    block_type = 'html'
    for idx in xrange(16):
        block_id = _make_block_id(block_type, idx)
        self.all_units.append((block_type, block_id))
