'Creates a hierarchy of blocks for testing
Each block\'s (version_agnostic) location is assigned as a field of the class and can be easily accessed'

def _create_block_hierarchy(self):

    BlockInfo = namedtuple('BlockInfo', 'field_name,    category,    display_name,    sub_tree')
    trees = [BlockInfo('chapter_x', 'chapter', 'Chapter_x', [BlockInfo('sequential_x1', 'sequential', 'Sequential_x1', [BlockInfo('vertical_x1a', 'vertical', 'Vertical_x1a', [BlockInfo('problem_x1a_1', 'problem', 'Problem_x1a_1', []), BlockInfo('problem_x1a_2', 'problem', 'Problem_x1a_2', []), BlockInfo('problem_x1a_3', 'problem', 'Problem_x1a_3', []), BlockInfo('html_x1a_1', 'html', 'HTML_x1a_1', [])]), BlockInfo('vertical_x1b', 'vertical', 'Vertical_x1b', [])]), BlockInfo('sequential_x2', 'sequential', 'Sequential_x2', [])]), BlockInfo('chapter_y', 'chapter', 'Chapter_y', [BlockInfo('sequential_y1', 'sequential', 'Sequential_y1', [BlockInfo('vertical_y1a', 'vertical', 'Vertical_y1a', [BlockInfo('problem_y1a_1', 'problem', 'Problem_y1a_1', []), BlockInfo('problem_y1a_2', 'problem', 'Problem_y1a_2', []), BlockInfo('problem_y1a_3', 'problem', 'Problem_y1a_3', [])])])])]
    def create_sub_tree(parent, block_info):
        '\n                                                recursive    function    that    creates    the    given    block    and    its    descendants\n                                                '
        block = self.store.create_child(self.user_id, parent.location, block_info.category, block_id=block_info.display_name, fields={'display_name': block_info.display_name})
        for tree in block_info.sub_tree:
            create_sub_tree(block, tree)
        setattr(self, block_info.field_name, block.location)
    with self.store.bulk_operations(self.course.id):
        for tree in trees:
            create_sub_tree(self.course, tree)
