I'm writing a test suite for a django project which needs to login via django-social-auth (its facebook backend) in order to access the website.
The method I'm taking now is:
problem is: I need to write a few tests which use the regular django unittest (not selenium). Any idea how I can login using the regular django unittest?
It's not an easy task since the oauth code is very coupled in social-auth. So you really need a oauth service answering.
What I have done is to patch the function social_auth.utils.urlopen
with a mock that returns previously recorded answers to trick django-social-auth into thinking it is talking with a real oauth provider.
It's a really hacky solution but allows me to test my custom social-auth pipeline in an isolated environment.