def get_can_use_permission(request, permission, permittee,
                           target_obj_or_class, redirect_to=None):
    assert(isinstance(target_obj_or_class, Aggregate))
    assert(
        isinstance(permittee, User) or
        isinstance(permittee, Project) or
        isinstance(permittee, Slice)
    )
    assert(permission.name == "can_use_aggregate")

    aggregate = target_obj_or_class
    
    try:
        next = request.session["breadcrumbs"][-1][1]
    except IndexError:
        next = redirect_to or reverse("home")
    
    if isinstance(permittee, Project):
        return HttpResponseRedirect(
            aggregate.as_leaf_class().add_to_project(permittee, next))
    elif isinstance(permittee, Slice):
        return HttpResponseRedirect(
            aggregate.as_leaf_class().add_to_slice(permittee, next))
    else: # isinstance(permittee, User)
        return HttpResponseRedirect(
            aggregate.as_leaf_class().add_to_user(permittee, next))
Create a ProtocolTestCase reading from stream.
dataset/ETHPy150Open fp7-ofelia/ocf/expedient/src/python/expedient/clearinghouse/aggregate/views.py/get_can_use_permission--crossover with--dataset/ETHPy150Open byt3bl33d3r/pth-toolkit/lib/python2.7/site-packages/samba/external/subunit/__init__.py/ProtocolTestCase.__init__