'Mock implementation of `has_access` used to control which blocks
have access to which children during tests.'

def _has_access(self, user, action, obj, course_key=None):

    if (action != 'load'):
        return self._old_has_access(user, action, obj, course_key)
    if isinstance(obj, XBlock):
        key = obj.scope_ids.usage_id
    elif isinstance(obj, UsageKey):
        key = obj
    if (key == self.parent.scope_ids.usage_id):
        return True
    return (key in self.children_for_user[user])
