Also, depending on your scenario, the classes might be overkill. You
could just as easily pass in a callable. In that case your view would
look something like this...
def suggest(request, usrid=None, get_friends=__get_friends):
current_user = request.facebook.user
facebook_friends = get_fr
Here is one approach...
class FBFriends:
def get_friends(self, current_user):
return __get_friends(current_user) # heavy call
def suggest(request, usrid=None, friend_source=FBFriends()):
current_user = request.facebook.user
facebook_friends = friend_source.get_friends(current_
In one of my views, I am doing a call to the Facebook graph API which
is a bit heavyweight and you also need a valid token. I am looking
into ways to use mocking/dependency injection to avoid having to do
this call during view tests. So let's say i have this view method:
def suggest(request, usrid
3 matches
Mail list logo