'Validate that the xblock info is internally consistent.'

def validate_xblock_info_consistency(self, xblock_info, has_ancestor_info=False, has_child_info=False, course_outline=False):

    self.assertIsNotNone(xblock_info['display_name'])
    self.assertIsNotNone(xblock_info['id'])
    self.assertIsNotNone(xblock_info['category'])
    self.assertTrue(xblock_info['published'])
    if has_ancestor_info:
        self.assertIsNotNone(xblock_info.get('ancestor_info', None))
        ancestors = xblock_info['ancestor_info']['ancestors']
        for ancestor in xblock_info['ancestor_info']['ancestors']:
            self.validate_xblock_info_consistency(ancestor, has_child_info=(ancestor == ancestors[0]), course_outline=course_outline)
    else:
        self.assertIsNone(xblock_info.get('ancestor_info', None))
    if has_child_info:
        self.assertIsNotNone(xblock_info.get('child_info', None))
        if xblock_info['child_info'].get('children', None):
            for child_response in xblock_info['child_info']['children']:
                self.validate_xblock_info_consistency(child_response, has_child_info=(not (child_response.get('child_info', None) is None)), course_outline=course_outline)
    else:
        self.assertIsNone(xblock_info.get('child_info', None))
