suggestion for dependency injection in view tests
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 = None):
current_user = request.facebook.user
facebook_friends = __get_friends(current_user) # heavy call
during testing I want to use something simple:
def suggest(request, usrid = None):
current_user = request.facebook.user
facebook_friends = [(2, 'John Doe'), (4, 'Jane Doe'), (5, 'The
Frog')]
Any suggestion how to do mocking/DI from a view?
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home