'Create a course and add blocks.'

def create_course_with_blocks(self, children_per_block=1, depth=1, store_type=ModuleStoreEnum.Type.mongo):

    with self.store.default_store(store_type):
        course = CourseFactory.create()
        display_name = 0
        with self.store.bulk_operations(course.id):
            blocks_at_next_level = [course]
            for __ in range(depth):
                blocks_at_current_level = blocks_at_next_level
                blocks_at_next_level = []
                for block in blocks_at_current_level:
                    for __ in range(children_per_block):
                        blocks_at_next_level += [ItemFactory.create(parent_location=block.scope_ids.usage_id, display_name=unicode(display_name))]
                        display_name += 1
    return course
